提交 0927d21f 编写于 作者: C Corey Minyard 提交者: Zheng Zengkai

ipmi:ssif: Check for NULL msg when handling events and messages

stable inclusion
from stable-v5.10.121
commit fa390c8b6256b1095341a9ab9f8fc0053f53bf9f
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6CQ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=fa390c8b6256b1095341a9ab9f8fc0053f53bf9f

--------------------------------

[ Upstream commit 7602b957 ]

Even though it's not possible to get into the SSIF_GETTING_MESSAGES and
SSIF_GETTING_EVENTS states without a valid message in the msg field,
it's probably best to be defensive here and check and print a log, since
that means something else went wrong.

Also add a default clause to that switch statement to release the lock
and print a log, in case the state variable gets messed up somehow.
Reported-by: NHaowen Bai <baihaowen@meizu.com>
Signed-off-by: NCorey Minyard <cminyard@mvista.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 ffab95d5
...@@ -840,6 +840,14 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result, ...@@ -840,6 +840,14 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
break; break;
case SSIF_GETTING_EVENTS: case SSIF_GETTING_EVENTS:
if (!msg) {
/* Should never happen, but just in case. */
dev_warn(&ssif_info->client->dev,
"No message set while getting events\n");
ipmi_ssif_unlock_cond(ssif_info, flags);
break;
}
if ((result < 0) || (len < 3) || (msg->rsp[2] != 0)) { if ((result < 0) || (len < 3) || (msg->rsp[2] != 0)) {
/* Error getting event, probably done. */ /* Error getting event, probably done. */
msg->done(msg); msg->done(msg);
...@@ -864,6 +872,14 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result, ...@@ -864,6 +872,14 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
break; break;
case SSIF_GETTING_MESSAGES: case SSIF_GETTING_MESSAGES:
if (!msg) {
/* Should never happen, but just in case. */
dev_warn(&ssif_info->client->dev,
"No message set while getting messages\n");
ipmi_ssif_unlock_cond(ssif_info, flags);
break;
}
if ((result < 0) || (len < 3) || (msg->rsp[2] != 0)) { if ((result < 0) || (len < 3) || (msg->rsp[2] != 0)) {
/* Error getting event, probably done. */ /* Error getting event, probably done. */
msg->done(msg); msg->done(msg);
...@@ -887,6 +903,13 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result, ...@@ -887,6 +903,13 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
deliver_recv_msg(ssif_info, msg); deliver_recv_msg(ssif_info, msg);
} }
break; break;
default:
/* Should never happen, but just in case. */
dev_warn(&ssif_info->client->dev,
"Invalid state in message done handling: %d\n",
ssif_info->ssif_state);
ipmi_ssif_unlock_cond(ssif_info, flags);
} }
flags = ipmi_ssif_lock_cond(ssif_info, &oflags); flags = ipmi_ssif_lock_cond(ssif_info, &oflags);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册