summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeelesh Gupta <neelegup@linux.vnet.ibm.com>2015-07-16 07:16:54 -0400
committerCorey Minyard <cminyard@mvista.com>2015-09-03 16:01:55 -0400
commitcca85f19c260df495a487495479c67803b25fa8a (patch)
tree91aed5a553ea8a627ac8b60301df2ad57a10cbdf
parent0fbcf4af7c8362d4691f9388efa57d0b14b34225 (diff)
ipmi/powernv: Fix potential invalid pointer dereference
If the OPAL call to receive the ipmi message fails, then we free up the smi message and return. But, the driver still holds the reference to old smi message in the 'cur_msg' which can potentially be accessed later and freed again leading to kernel oops. To fix it up, The kernel driver should reset the 'cur_msg' and send reply to the user in addition to freeing the message. Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com> Fixed a checkpatch warning dealing with an else after a return. Signed-off-by: Corey Minyard <cminyard@mvista.com>
-rw-r--r--drivers/char/ipmi/ipmi_powernv.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/char/ipmi/ipmi_powernv.c b/drivers/char/ipmi/ipmi_powernv.c
index 9b409c0f14f7..62c0c634280f 100644
--- a/drivers/char/ipmi/ipmi_powernv.c
+++ b/drivers/char/ipmi/ipmi_powernv.c
@@ -143,8 +143,15 @@ static int ipmi_powernv_recv(struct ipmi_smi_powernv *smi)
143 pr_devel("%s: -> %d (size %lld)\n", __func__, 143 pr_devel("%s: -> %d (size %lld)\n", __func__,
144 rc, rc == 0 ? size : 0); 144 rc, rc == 0 ? size : 0);
145 if (rc) { 145 if (rc) {
146 /* If came via the poll, and response was not yet ready */
147 if (rc == OPAL_EMPTY) {
148 spin_unlock_irqrestore(&smi->msg_lock, flags);
149 return 0;
150 }
151
152 smi->cur_msg = NULL;
146 spin_unlock_irqrestore(&smi->msg_lock, flags); 153 spin_unlock_irqrestore(&smi->msg_lock, flags);
147 ipmi_free_smi_msg(msg); 154 send_error_reply(smi, msg, IPMI_ERR_UNSPECIFIED);
148 return 0; 155 return 0;
149 } 156 }
150 157