From: Andrei Borzenkov Date: Tue, 27 Jan 2015 17:29:00 +0000 (+0300) Subject: linux/ofpath: fix descriptor leak X-Git-Tag: 2.02-beta3~462 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=637fc62699e7ae3f0057e1c56d330eb193fd40b6;p=thirdparty%2Fgrub.git linux/ofpath: fix descriptor leak Found by: Coverity scan --- diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index f716fd2fc..05b1ecdf8 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -122,6 +122,8 @@ find_obppath (const char *sysfs_path_orig) fd = open(path, O_RDONLY); if (fd < 0 || fstat (fd, &st) < 0) { + if (fd >= 0) + close (fd); snprintf(path, path_size, "%s/devspec", sysfs_path); fd = open(path, O_RDONLY); }