mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <guenter.roeck@ericsson.com>
To: Julia Lawall <julia@diku.dk>
Cc: Jean Delvare <khali@linux-fr.org>,
	"kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>,
	"lm-sensors@lm-sensors.org" <lm-sensors@lm-sensors.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drivers/hwmon/ibmaem.c: add missing kfree
Date: Tue, 9 Aug 2011 11:04:12 -0700	[thread overview]
Message-ID: <1312913052.9971.152.camel@groeck-laptop> (raw)
In-Reply-To: <1312902656-21520-1-git-send-email-julia@diku.dk>

On Tue, 2011-08-09 at 11:10 -0400, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.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@diku.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 */
> 



      reply	other threads:[~2011-08-09 18:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-09 15:10 Julia Lawall
2011-08-09 18:04 ` Guenter Roeck [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1312913052.9971.152.camel@groeck-laptop \
    --to=guenter.roeck@ericsson.com \
    --cc=julia@diku.dk \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®