Re: [PATCH 2/2] x86 platform drivers, hp-wmi: Fix two memleaks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




thanks,
Len Brown, Intel Open Source Technology Center

On Fri, 18 Dec 2009, Thomas Renninger wrote:

> CC: Carlos Corbacho <carlos@xxxxxxxxxxxxxxxxxxx>
> CC: Matthew Garrett <mjg59@xxxxxxxxxxxxx>
> CC: linux-acpi@xxxxxxxxxxxxxxx
> CC: Len Brown <lenb@xxxxxxxxxx>
> 
> Signed-off-by: Thomas Renninger <trenn@xxxxxxx>
> ---
>  drivers/platform/x86/hp-wmi.c |   10 +++++++++-
>  1 files changed, 9 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
> index 63c3e65..01a0913 100644
> --- a/drivers/platform/x86/hp-wmi.c
> +++ b/drivers/platform/x86/hp-wmi.c
> @@ -134,10 +134,15 @@ static int hp_wmi_perform_query(int query, int write, int value)
>  
>  	obj = output.pointer;
>  
> -	if (!obj || obj->type != ACPI_TYPE_BUFFER)
> +	if (!obj)
>  		return -EINVAL;
> +	else if (obj->type != ACPI_TYPE_BUFFER) {
> +		kfree(obj);
> +		return -EINVAL;
> +	}
>  
>  	bios_return = *((struct bios_return *)obj->buffer.pointer);
> +	kfree(obj);
>  	if (bios_return.return_code > 0)
>  		return bios_return.return_code * -1;
>  	else
> @@ -340,10 +345,13 @@ static void hp_wmi_notify(u32 value, void *context)
>  
>  	if (!obj || obj->type != ACPI_TYPE_BUFFER || obj->buffer.length != 8) {
>  		printk(KERN_INFO "HP WMI: Unknown response received\n");
> +		if (obj)
> +			kfree(obj);

WARNING: kfree(NULL) is safe this check is probably not required
#44: FILE: drivers/platform/x86/hp-wmi.c:349:
+		if (obj)
+			kfree(obj);

so I deleted "if(obj)" above and applied the patch.

thanks,
Len Brown, Intel Open Source Technology Center

>  		return;
>  	}
>  
>  	eventcode = *((u8 *) obj->buffer.pointer);
> +	kfree(obj);
>  	if (eventcode == 0x4)
>  		eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,
>  						0);
> -- 

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux