mirror of
https://github.com/containers/fuse-overlayfs.git
synced 2025-08-05 10:55:58 -04:00
main, rename: fix leak on error
fix a fd leak on the error exit path. Closes: https://github.com/containers/fuse-overlayfs/issues/289 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
af5cb1c04c
commit
d4188a4f59
18
main.c
18
main.c
@ -4404,8 +4404,8 @@ ovl_rename_direct (fuse_req_t req, fuse_ino_t parent, const char *name,
|
|||||||
struct ovl_data *lo = ovl_data (req);
|
struct ovl_data *lo = ovl_data (req);
|
||||||
int ret;
|
int ret;
|
||||||
int saved_errno;
|
int saved_errno;
|
||||||
int srcfd = -1;
|
cleanup_close int srcfd = -1;
|
||||||
int destfd = -1;
|
cleanup_close int destfd = -1;
|
||||||
struct ovl_node key;
|
struct ovl_node key;
|
||||||
bool destnode_is_whiteout = false;
|
bool destnode_is_whiteout = false;
|
||||||
|
|
||||||
@ -4590,20 +4590,12 @@ ovl_rename_direct (fuse_req_t req, fuse_ino_t parent, const char *name,
|
|||||||
node->loaded = 0;
|
node->loaded = 0;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
goto cleanup;
|
fuse_reply_err (req, 0);
|
||||||
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
fuse_reply_err (req, errno);
|
||||||
cleanup:
|
|
||||||
saved_errno = errno;
|
|
||||||
if (srcfd >= 0)
|
|
||||||
close (srcfd);
|
|
||||||
if (destfd >= 0)
|
|
||||||
close (destfd);
|
|
||||||
errno = saved_errno;
|
|
||||||
|
|
||||||
fuse_reply_err (req, ret == 0 ? 0 : errno);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user