diff options
author | Laszlo Papp <ext-laszlo.papp@nokia.com> | 2011-03-14 15:52:39 +0200 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2011-03-30 19:34:58 +0200 |
commit | 60eb44ee5eb2756465610b215968f176f4aaac6e (patch) | |
tree | 1190e79f978cb51cf75d31ae3f0d087a32fbfead /util | |
parent | 3a48e06de9c68666801522cd58b8acd5004b9c67 (diff) |
Fix resource leaks in fusermount
Diffstat (limited to 'util')
-rw-r--r-- | util/fusermount.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/util/fusermount.c b/util/fusermount.c index cd8a9c3..adab9b0 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -1054,8 +1054,7 @@ static int mount_fuse(const char *mnt, const char *opts) int mount_count = count_fuse_fs(); if (mount_count >= mount_max) { fprintf(stderr, "%s: too many FUSE filesystems mounted; mount_max=N can be set in /etc/fuse.conf\n", progname); - close(fd); - return -1; + goto fail_close_fd; } } @@ -1074,26 +1073,29 @@ static int mount_fuse(const char *mnt, const char *opts) if (mountpoint_fd != -1) close(mountpoint_fd); - if (res == -1) { - close(fd); - return -1; - } + if (res == -1) + goto fail_close_fd; if (geteuid() == 0) { res = add_mount(source, mnt, type, mnt_opts); if (res == -1) { /* Can't clean up mount in a non-racy way */ - close(fd); - return -1; + goto fail_close_fd; } } +out_free: free(source); free(type); free(mnt_opts); free(dev); return fd; + +fail_close_fd: + close(fd); + fd = -1; + goto out_free; } static int send_fd(int sock_fd, int fd) |