From 637fc62699e7ae3f0057e1c56d330eb193fd40b6 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 20:29:00 +0300 Subject: [PATCH] linux/ofpath: fix descriptor leak Found by: Coverity scan --- grub-core/osdep/linux/ofpath.c | 2 ++ 1 file changed, 2 insertions(+) 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); }