linux/ofpath: fix various memory leaks.

Found by: Coverity scan.
This commit is contained in:
Andrei Borzenkov 2015-01-26 21:41:29 +03:00
parent 6704abade6
commit e2a21238da
1 changed files with 7 additions and 1 deletions

View File

@ -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);