From: Julia Lawall Date: Tue, 9 Aug 2011 15:10:56 +0000 (-0400) Subject: hwmon: (ibmaem) add missing kfree X-Git-Tag: v2.6.32.46~14 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=3ca969416e0fda795c58508d3fa918572326783d;p=karo-tx-linux.git hwmon: (ibmaem) add missing kfree commit 66a89b2164e2d30661edbd1953eacf0594d8203a upstream. rs_resp is dynamically allocated in aem_read_sensor(), 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 Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c index 405d3fb5d76f..a818105d9110 100644 --- a/drivers/hwmon/ibmaem.c +++ b/drivers/hwmon/ibmaem.c @@ -429,13 +429,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) { @@ -460,8 +462,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 */