]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
linux/ofpath: fix descriptor leak
authorAndrei Borzenkov <arvidjaar@gmail.com>
Tue, 27 Jan 2015 17:29:00 +0000 (20:29 +0300)
committerAndrei Borzenkov <arvidjaar@gmail.com>
Tue, 27 Jan 2015 17:29:00 +0000 (20:29 +0300)
Found by: Coverity scan

grub-core/osdep/linux/ofpath.c

index f716fd2fc9f38800c9d5294e6c9c4c0b906597b8..05b1ecdf81a3d3f612fa2028629965701800d1f4 100644 (file)
@@ -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);
        }