Skip to content

Commit cae66f1

Browse files
committed
ipmi:si: Fix check for a misbehaving BMC
There is a race on checking the state in the sender, it needs to be checked under a lock. But you also need a check to avoid issues with a misbehaving BMC for run to completion mode. So leave the check at the beginning for run to completion, and add a check under the lock to avoid the race. Reported-by: Rafael J. Wysocki <rafael@kernel.org> Fixes: bc3a9d2 ("ipmi:si: Gracefully handle if the BMC is non-functional") Cc: stable@vger.kernel.org # 4.18 Signed-off-by: Corey Minyard <corey@minyard.net> Reviewed-by: Rafael J. Wysocki (Intel) <rafael@kernel.org>
1 parent 62cd145 commit cae66f1

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

drivers/char/ipmi/ipmi_si_intf.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -924,9 +924,14 @@ static int sender(void *send_info, struct ipmi_smi_msg *msg)
924924
{
925925
struct smi_info *smi_info = send_info;
926926
unsigned long flags;
927+
int rv = IPMI_CC_NO_ERROR;
927928

928929
debug_timestamp(smi_info, "Enqueue");
929930

931+
/*
932+
* Check here for run to completion mode. A check under lock is
933+
* later.
934+
*/
930935
if (smi_info->si_state == SI_HOSED)
931936
return IPMI_BUS_ERR;
932937

@@ -940,18 +945,15 @@ static int sender(void *send_info, struct ipmi_smi_msg *msg)
940945
}
941946

942947
spin_lock_irqsave(&smi_info->si_lock, flags);
943-
/*
944-
* The following two lines don't need to be under the lock for
945-
* the lock's sake, but they do need SMP memory barriers to
946-
* avoid getting things out of order. We are already claiming
947-
* the lock, anyway, so just do it under the lock to avoid the
948-
* ordering problem.
949-
*/
950-
BUG_ON(smi_info->waiting_msg);
951-
smi_info->waiting_msg = msg;
952-
check_start_timer_thread(smi_info);
948+
if (smi_info->si_state == SI_HOSED) {
949+
rv = IPMI_BUS_ERR;
950+
} else {
951+
BUG_ON(smi_info->waiting_msg);
952+
smi_info->waiting_msg = msg;
953+
check_start_timer_thread(smi_info);
954+
}
953955
spin_unlock_irqrestore(&smi_info->si_lock, flags);
954-
return IPMI_CC_NO_ERROR;
956+
return rv;
955957
}
956958

957959
static void set_run_to_completion(void *send_info, bool i_run_to_completion)

0 commit comments

Comments
 (0)