lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1312913052.9971.152.camel@groeck-laptop>
Date:	Tue, 9 Aug 2011 11:04:12 -0700
From:	Guenter Roeck <guenter.roeck@...csson.com>
To:	Julia Lawall <julia@...u.dk>
CC:	Jean Delvare <khali@...ux-fr.org>,
	"kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>,
	"lm-sensors@...sensors.org" <lm-sensors@...sensors.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] drivers/hwmon/ibmaem.c: add missing kfree

On Tue, 2011-08-09 at 11:10 -0400, Julia Lawall wrote:
> From: Julia Lawall <julia@...u.dk>
> 
> rs_resp is dynamically allocated in this function, so it should be freed
> before exiting in every case.  This collects the kfree and the return at
> the end of the function.
> 
> Signed-off-by: Julia Lawall <julia@...u.dk>
> 
Good catch. Applied.

Thanks,
Guenter


> ---
>  drivers/hwmon/ibmaem.c |   15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
> index 058e0ae..783d0c1 100644
> --- a/drivers/hwmon/ibmaem.c
> +++ b/drivers/hwmon/ibmaem.c
> @@ -399,13 +399,15 @@ static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg,
>  	aem_send_message(ipmi);
>  
>  	res = wait_for_completion_timeout(&ipmi->read_complete, IPMI_TIMEOUT);
> -	if (!res)
> -		return -ETIMEDOUT;
> +	if (!res) {
> +		res = -ETIMEDOUT;
> +		goto out;
> +	}
>  
>  	if (ipmi->rx_result || ipmi->rx_msg_len != rs_size ||
>  	    memcmp(&rs_resp->id, &system_x_id, sizeof(system_x_id))) {
> -		kfree(rs_resp);
> -		return -ENOENT;
> +		res = -ENOENT;
> +		goto out;
>  	}
>  
>  	switch (size) {
> @@ -430,8 +432,11 @@ static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg,
>  		break;
>  	}
>  	}
> +	res = 0;
>  
> -	return 0;
> +out:
> +	kfree(rs_resp);
> +	return res;
>  }
>  
>  /* Update AEM energy registers */
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ