linux/ofpath: fix various memory leaks.
Found by: Coverity scan.
This commit is contained in:
parent
6704abade6
commit
e2a21238da
1 changed files with 7 additions and 1 deletions
|
@ -128,6 +128,8 @@ find_obppath (const char *sysfs_path_orig)
|
||||||
|
|
||||||
if (fd < 0 || fstat (fd, &st) < 0)
|
if (fd < 0 || fstat (fd, &st) < 0)
|
||||||
{
|
{
|
||||||
|
if (fd >= 0)
|
||||||
|
close (fd);
|
||||||
kill_trailing_dir(sysfs_path);
|
kill_trailing_dir(sysfs_path);
|
||||||
if (!strcmp(sysfs_path, "/sys"))
|
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));
|
grub_util_info (_("cannot read `%s': %s"), path, strerror (errno));
|
||||||
close(fd);
|
close(fd);
|
||||||
|
free (path);
|
||||||
|
free (of_path);
|
||||||
|
free (sysfs_path);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -480,6 +485,7 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
|
||||||
snprintf(disk, sizeof (disk),
|
snprintf(disk, sizeof (disk),
|
||||||
"/sas/%s@%lx,%lu:%c", disk_name, sas_address, longlun, 'a' + (part - 1));
|
"/sas/%s@%lx,%lu:%c", disk_name, sas_address, longlun, 'a' + (part - 1));
|
||||||
}
|
}
|
||||||
|
free (lunstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strcat(of_path, disk);
|
strcat(of_path, disk);
|
||||||
|
@ -530,7 +536,7 @@ grub_util_devname_to_ofpath (const char *sys_devname)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
grub_util_warn (_("unknown device type %s\n"), device);
|
grub_util_warn (_("unknown device type %s\n"), device);
|
||||||
return NULL;
|
ofpath = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
free (devnode);
|
free (devnode);
|
||||||
|
|
Loading…
Reference in a new issue