Skip to content

Commit

Permalink
hwmon: (ibmaem) add missing kfree
Browse files Browse the repository at this point in the history
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 <julia@diku.dk>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Cc: stable@kernel.org # 2.6.27+
  • Loading branch information
Julia Lawall authored and Guenter Roeck committed Aug 11, 2011
1 parent 3a2805e commit 66a89b2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions drivers/hwmon/ibmaem.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,13 +432,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) {
Expand All @@ -463,8 +465,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 */
Expand Down

0 comments on commit 66a89b2

Please sign in to comment.