Skip to content

Commit f002612

Browse files
Kamlakant Patelcminyard
authored andcommitted
ipmi_ssif: Fix kernel panic at msg_done_handler
This happens when BMC doesn't return any data and the code is trying to print the value of data[2]. Getting following crash: [ 484.728410] Unable to handle kernel NULL pointer dereference at virtual address 00000002 [ 484.736496] pgd = ffff0000094a2000 [ 484.739885] [00000002] *pgd=00000047fcffe003, *pud=00000047fcffd003, *pmd=0000000000000000 [ 484.748158] Internal error: Oops: 96000005 [#1] SMP [...] [ 485.101451] Call trace: [...] [ 485.188473] [<ffff000000a46e68>] msg_done_handler+0x668/0x700 [ipmi_ssif] [ 485.195249] [<ffff000000a456b8>] ipmi_ssif_thread+0x110/0x128 [ipmi_ssif] [ 485.202038] [<ffff0000080f1430>] kthread+0x108/0x138 [ 485.206994] [<ffff0000080838e0>] ret_from_fork+0x10/0x30 [ 485.212294] Code: aa1903e1 aa1803e0 b900227f 95fef6a5 (39400aa3) Adding a check to validate the data len before printing data[2] to fix this issue. Signed-off-by: Kamlakant Patel <[email protected]> Signed-off-by: Corey Minyard <[email protected]>
1 parent bc48fa1 commit f002612

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/char/ipmi/ipmi_ssif.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
757757
ssif_info->ssif_state = SSIF_NORMAL;
758758
ipmi_ssif_unlock_cond(ssif_info, flags);
759759
pr_warn(PFX "Error getting flags: %d %d, %x\n",
760-
result, len, data[2]);
760+
result, len, (len >= 3) ? data[2] : 0);
761761
} else if (data[0] != (IPMI_NETFN_APP_REQUEST | 1) << 2
762762
|| data[1] != IPMI_GET_MSG_FLAGS_CMD) {
763763
/*
@@ -779,7 +779,7 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
779779
if ((result < 0) || (len < 3) || (data[2] != 0)) {
780780
/* Error clearing flags */
781781
pr_warn(PFX "Error clearing flags: %d %d, %x\n",
782-
result, len, data[2]);
782+
result, len, (len >= 3) ? data[2] : 0);
783783
} else if (data[0] != (IPMI_NETFN_APP_REQUEST | 1) << 2
784784
|| data[1] != IPMI_CLEAR_MSG_FLAGS_CMD) {
785785
pr_warn(PFX "Invalid response clearing flags: %x %x\n",

0 commit comments

Comments
 (0)