Imran Zaman
2015-Sep-09 10:36 UTC
[syslinux] [PATCH v1 1/1] extlinux: fix file descriptors leak
file descriptors are closed when not in use Signed-off-by: Imran Zaman <imran.zaman at intel.com> --- extlinux/main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/extlinux/main.c b/extlinux/main.c index 09740bd..bc7ded3 100644 --- a/extlinux/main.c +++ b/extlinux/main.c @@ -580,6 +580,7 @@ int ext2_fat_install_file(const char *path, int devfd, struct stat *rst) goto bail; } + close(fd); free(file); free(oldfile); free(c32file); @@ -797,6 +798,8 @@ static char * get_default_subvol(char * rootdir, char * subvol) } if (ret <= 0) { subvol[0] = '\0'; + if (fd >= 0) + close(fd); return NULL; } @@ -831,6 +834,8 @@ static char * get_default_subvol(char * rootdir, char * subvol) if (ret < 0) { fprintf(stderr, "ERROR: can't perform the search\n"); subvol[0] = '\0'; + if (fd >= 0) + close(fd); return NULL; } /* the ioctl returns the number of item it found in nr_items */ @@ -891,6 +896,8 @@ static char * get_default_subvol(char * rootdir, char * subvol) if (defaultsubvolid == 0) { subvol[0] = '\0'; + if (fd >= 0) + close(fd); return NULL; } @@ -922,6 +929,8 @@ static char * get_default_subvol(char * rootdir, char * subvol) if (ret < 0) { fprintf(stderr, "ERROR: can't perform the search\n"); subvol[0] = '\0'; + if (fd >= 0) + close(fd); return NULL; } /* the ioctl returns the number of item it found in nr_items */ @@ -975,6 +984,9 @@ static char * get_default_subvol(char * rootdir, char * subvol) } else break; } + + if (fd >= 0) + close(fd); return subvol; } -- 1.9.1 --------------------------------------------------------------------- Intel Finland Oy Registered Address: PL 281, 00181 Helsinki Business Identity Code: 0357606 - 4 Domiciled in Helsinki This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.