From: Andrei Borzenkov Date: Mon, 26 Jan 2015 18:38:40 +0000 (+0300) Subject: linux/getroot: fix descriptor leak. X-Git-Tag: 2.02-beta3~480 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6704abade6674a91d8c652a7e4596ca3421411b6;p=thirdparty%2Fgrub.git linux/getroot: fix descriptor leak. Found by: Coverity scan. --- diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c index f48b81aed..a2e360f52 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -360,8 +360,10 @@ get_btrfs_fs_prefix (const char *mount_path) ret[1+namelen] = '\0'; } if (!ret) - return xstrdup ("/"); + ret = xstrdup ("/"); + close (fd); return ret; + fail: free (ret); close (fd);