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
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to