Skip to content

Commit 66a89b2

Browse files
Julia LawallGuenter Roeck
authored andcommitted
hwmon: (ibmaem) add missing kfree
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 <[email protected]> Signed-off-by: Guenter Roeck <[email protected]> Cc: [email protected] # 2.6.27+
1 parent 3a2805e commit 66a89b2

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

drivers/hwmon/ibmaem.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,15 @@ static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg,
432432
aem_send_message(ipmi);
433433

434434
res = wait_for_completion_timeout(&ipmi->read_complete, IPMI_TIMEOUT);
435-
if (!res)
436-
return -ETIMEDOUT;
435+
if (!res) {
436+
res = -ETIMEDOUT;
437+
goto out;
438+
}
437439

438440
if (ipmi->rx_result || ipmi->rx_msg_len != rs_size ||
439441
memcmp(&rs_resp->id, &system_x_id, sizeof(system_x_id))) {
440-
kfree(rs_resp);
441-
return -ENOENT;
442+
res = -ENOENT;
443+
goto out;
442444
}
443445

444446
switch (size) {
@@ -463,8 +465,11 @@ static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg,
463465
break;
464466
}
465467
}
468+
res = 0;
466469

467-
return 0;
470+
out:
471+
kfree(rs_resp);
472+
return res;
468473
}
469474

470475
/* Update AEM energy registers */

0 commit comments

Comments
 (0)