Revert "ipmi: fix msg stack when IPMI is disconnected"
authorCorey Minyard <corey@minyard.net>
Wed, 20 Aug 2025 16:03:13 +0000 (11:03 -0500)
committerCorey Minyard <corey@minyard.net>
Mon, 8 Sep 2025 15:08:25 +0000 (10:08 -0500)
This reverts commit c608966f3f9c2dca596967501d00753282b395fc.

This patch has a subtle bug that can cause the IPMI driver to go into an
infinite loop if the BMC misbehaves in a certain way.  Apparently
certain BMCs do misbehave this way because several reports have come in
recently about this.

Signed-off-by: Corey Minyard <corey@minyard.net>
Tested-by: Eric Hagberg <ehagberg@janestreet.com>
Cc: <stable@vger.kernel.org> # 6.2
drivers/char/ipmi/ipmi_kcs_sm.c

index ecfcb50..efda90d 100644 (file)
@@ -122,10 +122,10 @@ struct si_sm_data {
        unsigned long  error0_timeout;
 };
 
-static unsigned int init_kcs_data_with_state(struct si_sm_data *kcs,
-                                 struct si_sm_io *io, enum kcs_states state)
+static unsigned int init_kcs_data(struct si_sm_data *kcs,
+                                 struct si_sm_io *io)
 {
-       kcs->state = state;
+       kcs->state = KCS_IDLE;
        kcs->io = io;
        kcs->write_pos = 0;
        kcs->write_count = 0;
@@ -140,12 +140,6 @@ static unsigned int init_kcs_data_with_state(struct si_sm_data *kcs,
        return 2;
 }
 
-static unsigned int init_kcs_data(struct si_sm_data *kcs,
-                                 struct si_sm_io *io)
-{
-       return init_kcs_data_with_state(kcs, io, KCS_IDLE);
-}
-
 static inline unsigned char read_status(struct si_sm_data *kcs)
 {
        return kcs->io->inputb(kcs->io, 1);
@@ -276,7 +270,7 @@ static int start_kcs_transaction(struct si_sm_data *kcs, unsigned char *data,
        if (size > MAX_KCS_WRITE_SIZE)
                return IPMI_REQ_LEN_EXCEEDED_ERR;
 
-       if (kcs->state != KCS_IDLE) {
+       if ((kcs->state != KCS_IDLE) && (kcs->state != KCS_HOSED)) {
                dev_warn(kcs->io->dev, "KCS in invalid state %d\n", kcs->state);
                return IPMI_NOT_IN_MY_STATE_ERR;
        }
@@ -501,7 +495,7 @@ static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time)
        }
 
        if (kcs->state == KCS_HOSED) {
-               init_kcs_data_with_state(kcs, kcs->io, KCS_ERROR0);
+               init_kcs_data(kcs, kcs->io);
                return SI_SM_HOSED;
        }