svn commit: r298381 - head/usr.sbin/mpsutil
Baptiste Daroussin
bapt at FreeBSD.org
Wed Apr 20 21:32:35 UTC 2016
Author: bapt
Date: Wed Apr 20 21:32:34 2016
New Revision: 298381
URL: https://svnweb.freebsd.org/changeset/base/298381
Log:
Plug various resources leak
While here fix a test logic
Reported by: coverity
CID: 1332096, 1332097, 1332098, 1332099, 1332100, 1332101, 1332102
MFC after: 1 week
Modified:
head/usr.sbin/mpsutil/mps_show.c
Modified: head/usr.sbin/mpsutil/mps_show.c
==============================================================================
--- head/usr.sbin/mpsutil/mps_show.c Wed Apr 20 21:30:56 2016 (r298380)
+++ head/usr.sbin/mpsutil/mps_show.c Wed Apr 20 21:32:34 2016 (r298381)
@@ -139,15 +139,19 @@ show_adapter(int ac, char **av)
if (sas0 == NULL) {
error = errno;
warn("Error retrieving SAS IO Unit page %d", IOCStatus);
+ free(sas0);
+ close(fd);
return (error);
}
sas1 = mps_read_extended_config_page(fd,
MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT,
MPI2_SASIOUNITPAGE1_PAGEVERSION, 1, 0, &IOCStatus);
- if (sas0 == NULL) {
+ if (sas1 == NULL) {
error = errno;
warn("Error retrieving SAS IO Unit page %d", IOCStatus);
+ free(sas0);
+ close(fd);
return (error);
}
printf("\n");
@@ -266,12 +270,14 @@ show_adapters(int ac, char **av)
error = errno;
warn("Failed to get controller info");
close(fd);
+ free(facts);
return (error);
}
if (man0->Header.PageLength < sizeof(*man0) / 4) {
warnx("Invalid controller info");
close(fd);
free(man0);
+ free(facts);
return (EINVAL);
}
printf("/dev/mp%s%d\t%16s %16s %08x\n",
@@ -476,6 +482,7 @@ show_devices(int ac, char **av)
break;
error = errno;
warn("Error retrieving device page");
+ close(fd);
return (error);
}
handle = device->DevHandle;
@@ -515,6 +522,8 @@ show_devices(int ac, char **av)
error = errno;
warn("Error retrieving expander page 1: 0x%x",
IOCStatus);
+ close(fd);
+ free(device);
return (error);
}
speed = " ";
@@ -579,6 +588,7 @@ show_enclosures(int ac, char **av)
break;
error = errno;
warn("Error retrieving enclosure page");
+ close(fd);
return (error);
}
type = get_enc_type(enc->Flags, &issep);
@@ -629,6 +639,7 @@ show_expanders(int ac, char **av)
break;
error = errno;
warn("Error retrieving expander page 0");
+ close(fd);
return (error);
}
@@ -766,6 +777,7 @@ show_cfgpage(int ac, char **av)
printf("Page 0x%x: %s %d, %s\n", page, pgname, num, pgattr);
hexdump(data, len, NULL, HD_REVERSED | 4);
free(data);
+ close(fd);
return (0);
}
More information about the svn-src-head
mailing list