Date: Wed, 8 Jun 2016 22:18:15 -0400 From: John Baldwin <jhb@FreeBSD.org> To: "Conrad E. Meyer" <cem@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r301562 - head/sys/dev/acpica Message-ID: <1038ce21-2441-06f0-b849-4c4eab1c3b0e@FreeBSD.org> In-Reply-To: <201606071908.u57J8EZI011734@repo.freebsd.org> References: <201606071908.u57J8EZI011734@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 6/7/16 3:08 PM, Conrad E. Meyer wrote: > Author: cem > Date: Tue Jun 7 19:08:13 2016 > New Revision: 301562 > URL: https://svnweb.freebsd.org/changeset/base/301562 > > Log: > Fix a minor leak in ACPI thermal > > Introduced in r301518. > > Reported by: Coverity > CID: 1356266 > Sponsored by: EMC / Isilon Storage Division > > Modified: > head/sys/dev/acpica/acpi_thermal.c > > Modified: head/sys/dev/acpica/acpi_thermal.c > ============================================================================== > --- head/sys/dev/acpica/acpi_thermal.c Tue Jun 7 18:50:36 2016 (r301561) > +++ head/sys/dev/acpica/acpi_thermal.c Tue Jun 7 19:08:13 2016 (r301562) > @@ -335,8 +335,10 @@ acpi_tz_startup(void *arg __unused) > int devcount, error, i; > > devclass_get_devices(acpi_tz_devclass, &devs, &devcount); > - if (devcount == 0) > + if (devcount == 0) { > + free(devs, M_TEMP); > return; > + } Ugh, I assumed we didn't return anything for a count of zero. I kind of think it's a bug that we return malloc(0) instead of NULL in that case. Looks like if malloc fails devclass_get_devices() doesn't set 'dev' or 'devcount' at all. We need to fail if it returns non-zero. -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1038ce21-2441-06f0-b849-4c4eab1c3b0e>