diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index 8f24bc9e8..4cc171cb5 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -128,6 +128,8 @@ find_obppath (const char *sysfs_path_orig) if (fd < 0 || fstat (fd, &st) < 0) { + if (fd >= 0) + close (fd); kill_trailing_dir(sysfs_path); if (!strcmp(sysfs_path, "/sys")) { @@ -147,6 +149,9 @@ find_obppath (const char *sysfs_path_orig) { grub_util_info (_("cannot read `%s': %s"), path, strerror (errno)); close(fd); + free (path); + free (of_path); + free (sysfs_path); return NULL; } close(fd); @@ -480,6 +485,7 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev snprintf(disk, sizeof (disk), "/sas/%s@%lx,%lu:%c", disk_name, sas_address, longlun, 'a' + (part - 1)); } + free (lunstr); } } strcat(of_path, disk); @@ -530,7 +536,7 @@ grub_util_devname_to_ofpath (const char *sys_devname) else { grub_util_warn (_("unknown device type %s\n"), device); - return NULL; + ofpath = NULL; } free (devnode);