If devclass_get_devices() returns success but a count of 0, free the

pointer.  If kernel malloc(0) returns a valid pointer, it needs to be
freed.  If it returns NULL, it's ok to free this also.

Submitted by:	pjd
Reviewed by:	imp, dfr
Obtained from:	Coverity Prevent
This commit is contained in:
Nate Lawson 2005-05-20 05:00:43 +00:00
parent 201aed7a77
commit 1c9ec53854
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=146431

View File

@ -2357,8 +2357,11 @@ acpi_wake_sysctl_walk(device_t dev)
ACPI_STATUS status;
error = device_get_children(dev, &devlist, &numdevs);
if (error != 0 || numdevs == 0)
if (error != 0 || numdevs == 0) {
if (numdevs == 0)
free(devlist, M_TEMP);
return (error);
}
for (i = 0; i < numdevs; i++) {
child = devlist[i];
acpi_wake_sysctl_walk(child);