public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 6.12-stable tree
@ 2026-05-01 10:58 gregkh
  2026-05-01 13:56 ` [PATCH 6.12.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
  0 siblings, 1 reply; 19+ messages in thread
From: gregkh @ 2026-05-01 10:58 UTC (permalink / raw)
  To: corey, 252270051; +Cc: stable


The patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 75c486cb1bcaa1a3ec3a6438498176a3a4998ae4
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026050146-duckbill-exile-3382@gregkh' --subject-prefix 'PATCH 6.12.y' HEAD^..

Possible dependencies:



thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 75c486cb1bcaa1a3ec3a6438498176a3a4998ae4 Mon Sep 17 00:00:00 2001
From: Corey Minyard <corey@minyard.net>
Date: Mon, 13 Apr 2026 08:00:23 -0500
Subject: [PATCH] ipmi:ssif: Clean up kthread on errors

If an error occurs after the ssif kthread is created, but before the
main IPMI code starts the ssif interface, the ssif kthread will not
be stopped.

So make sure the kthread is stopped on an error condition if it is
running.

Fixes: 259307074bfc ("ipmi: Add SMBus interface driver (SSIF)")
Reported-by: Li Xiao <<252270051@hdu.edu.cn>
Cc: stable@vger.kernel.org
Reviewed-by: Li Xiao <252270051@hdu.edu.cn>
Signed-off-by: Corey Minyard <corey@minyard.net>

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index ce918fe987c6..b49500a1bd36 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -1268,8 +1268,10 @@ static void shutdown_ssif(void *send_info)
 	ssif_info->stopping = true;
 	timer_delete_sync(&ssif_info->watch_timer);
 	timer_delete_sync(&ssif_info->retry_timer);
-	if (ssif_info->thread)
+	if (ssif_info->thread) {
 		kthread_stop(ssif_info->thread);
+		ssif_info->thread = NULL;
+	}
 }
 
 static void ssif_remove(struct i2c_client *client)
@@ -1912,6 +1914,15 @@ static int ssif_probe(struct i2c_client *client)
 
  out:
 	if (rv) {
+		/*
+		 * If ipmi_register_smi() starts the interface, it will
+		 * call shutdown and that will free the thread and set
+		 * it to NULL.  Otherwise it must be freed here.
+		 */
+		if (ssif_info->thread) {
+			kthread_stop(ssif_info->thread);
+			ssif_info->thread = NULL;
+		}
 		if (addr_info)
 			addr_info->client = NULL;
 


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 6.6-stable tree
@ 2026-05-01 10:58 gregkh
  2026-05-01 14:06 ` [PATCH 6.6.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
  0 siblings, 1 reply; 19+ messages in thread
From: gregkh @ 2026-05-01 10:58 UTC (permalink / raw)
  To: corey, 252270051; +Cc: stable


The patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x 75c486cb1bcaa1a3ec3a6438498176a3a4998ae4
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026050147-kinfolk-perennial-0e04@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^..

Possible dependencies:



thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 75c486cb1bcaa1a3ec3a6438498176a3a4998ae4 Mon Sep 17 00:00:00 2001
From: Corey Minyard <corey@minyard.net>
Date: Mon, 13 Apr 2026 08:00:23 -0500
Subject: [PATCH] ipmi:ssif: Clean up kthread on errors

If an error occurs after the ssif kthread is created, but before the
main IPMI code starts the ssif interface, the ssif kthread will not
be stopped.

So make sure the kthread is stopped on an error condition if it is
running.

Fixes: 259307074bfc ("ipmi: Add SMBus interface driver (SSIF)")
Reported-by: Li Xiao <<252270051@hdu.edu.cn>
Cc: stable@vger.kernel.org
Reviewed-by: Li Xiao <252270051@hdu.edu.cn>
Signed-off-by: Corey Minyard <corey@minyard.net>

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index ce918fe987c6..b49500a1bd36 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -1268,8 +1268,10 @@ static void shutdown_ssif(void *send_info)
 	ssif_info->stopping = true;
 	timer_delete_sync(&ssif_info->watch_timer);
 	timer_delete_sync(&ssif_info->retry_timer);
-	if (ssif_info->thread)
+	if (ssif_info->thread) {
 		kthread_stop(ssif_info->thread);
+		ssif_info->thread = NULL;
+	}
 }
 
 static void ssif_remove(struct i2c_client *client)
@@ -1912,6 +1914,15 @@ static int ssif_probe(struct i2c_client *client)
 
  out:
 	if (rv) {
+		/*
+		 * If ipmi_register_smi() starts the interface, it will
+		 * call shutdown and that will free the thread and set
+		 * it to NULL.  Otherwise it must be freed here.
+		 */
+		if (ssif_info->thread) {
+			kthread_stop(ssif_info->thread);
+			ssif_info->thread = NULL;
+		}
 		if (addr_info)
 			addr_info->client = NULL;
 


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 6.1-stable tree
@ 2026-05-01 10:58 gregkh
  2026-05-01 14:19 ` [PATCH 6.1.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
  0 siblings, 1 reply; 19+ messages in thread
From: gregkh @ 2026-05-01 10:58 UTC (permalink / raw)
  To: corey, 252270051; +Cc: stable


The patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 75c486cb1bcaa1a3ec3a6438498176a3a4998ae4
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026050147-trio-dangling-a9ed@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..

Possible dependencies:



thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 75c486cb1bcaa1a3ec3a6438498176a3a4998ae4 Mon Sep 17 00:00:00 2001
From: Corey Minyard <corey@minyard.net>
Date: Mon, 13 Apr 2026 08:00:23 -0500
Subject: [PATCH] ipmi:ssif: Clean up kthread on errors

If an error occurs after the ssif kthread is created, but before the
main IPMI code starts the ssif interface, the ssif kthread will not
be stopped.

So make sure the kthread is stopped on an error condition if it is
running.

Fixes: 259307074bfc ("ipmi: Add SMBus interface driver (SSIF)")
Reported-by: Li Xiao <<252270051@hdu.edu.cn>
Cc: stable@vger.kernel.org
Reviewed-by: Li Xiao <252270051@hdu.edu.cn>
Signed-off-by: Corey Minyard <corey@minyard.net>

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index ce918fe987c6..b49500a1bd36 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -1268,8 +1268,10 @@ static void shutdown_ssif(void *send_info)
 	ssif_info->stopping = true;
 	timer_delete_sync(&ssif_info->watch_timer);
 	timer_delete_sync(&ssif_info->retry_timer);
-	if (ssif_info->thread)
+	if (ssif_info->thread) {
 		kthread_stop(ssif_info->thread);
+		ssif_info->thread = NULL;
+	}
 }
 
 static void ssif_remove(struct i2c_client *client)
@@ -1912,6 +1914,15 @@ static int ssif_probe(struct i2c_client *client)
 
  out:
 	if (rv) {
+		/*
+		 * If ipmi_register_smi() starts the interface, it will
+		 * call shutdown and that will free the thread and set
+		 * it to NULL.  Otherwise it must be freed here.
+		 */
+		if (ssif_info->thread) {
+			kthread_stop(ssif_info->thread);
+			ssif_info->thread = NULL;
+		}
 		if (addr_info)
 			addr_info->client = NULL;
 


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 5.10-stable tree
@ 2026-05-01 10:58 gregkh
  2026-05-01 14:54 ` [PATCH 5.10.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
  2026-05-01 16:20 ` [PATCH 5.10.y] ipmi:ssif: Fix a thread shutdown issue Corey Minyard
  0 siblings, 2 replies; 19+ messages in thread
From: gregkh @ 2026-05-01 10:58 UTC (permalink / raw)
  To: corey, 252270051; +Cc: stable


The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 75c486cb1bcaa1a3ec3a6438498176a3a4998ae4
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026050148-irregular-kite-7f24@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^..

Possible dependencies:



thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 75c486cb1bcaa1a3ec3a6438498176a3a4998ae4 Mon Sep 17 00:00:00 2001
From: Corey Minyard <corey@minyard.net>
Date: Mon, 13 Apr 2026 08:00:23 -0500
Subject: [PATCH] ipmi:ssif: Clean up kthread on errors

If an error occurs after the ssif kthread is created, but before the
main IPMI code starts the ssif interface, the ssif kthread will not
be stopped.

So make sure the kthread is stopped on an error condition if it is
running.

Fixes: 259307074bfc ("ipmi: Add SMBus interface driver (SSIF)")
Reported-by: Li Xiao <<252270051@hdu.edu.cn>
Cc: stable@vger.kernel.org
Reviewed-by: Li Xiao <252270051@hdu.edu.cn>
Signed-off-by: Corey Minyard <corey@minyard.net>

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index ce918fe987c6..b49500a1bd36 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -1268,8 +1268,10 @@ static void shutdown_ssif(void *send_info)
 	ssif_info->stopping = true;
 	timer_delete_sync(&ssif_info->watch_timer);
 	timer_delete_sync(&ssif_info->retry_timer);
-	if (ssif_info->thread)
+	if (ssif_info->thread) {
 		kthread_stop(ssif_info->thread);
+		ssif_info->thread = NULL;
+	}
 }
 
 static void ssif_remove(struct i2c_client *client)
@@ -1912,6 +1914,15 @@ static int ssif_probe(struct i2c_client *client)
 
  out:
 	if (rv) {
+		/*
+		 * If ipmi_register_smi() starts the interface, it will
+		 * call shutdown and that will free the thread and set
+		 * it to NULL.  Otherwise it must be freed here.
+		 */
+		if (ssif_info->thread) {
+			kthread_stop(ssif_info->thread);
+			ssif_info->thread = NULL;
+		}
 		if (addr_info)
 			addr_info->client = NULL;
 


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 5.15-stable tree
@ 2026-05-01 10:58 gregkh
  2026-05-01 14:27 ` [PATCH 5.15.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
  2026-05-01 16:11 ` [PATCH 5.15.y] ipmi:ssif: Fix a thread shutdown issue Corey Minyard
  0 siblings, 2 replies; 19+ messages in thread
From: gregkh @ 2026-05-01 10:58 UTC (permalink / raw)
  To: corey, 252270051; +Cc: stable


The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 75c486cb1bcaa1a3ec3a6438498176a3a4998ae4
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026050148-politely-tabloid-3059@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..

Possible dependencies:



thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 75c486cb1bcaa1a3ec3a6438498176a3a4998ae4 Mon Sep 17 00:00:00 2001
From: Corey Minyard <corey@minyard.net>
Date: Mon, 13 Apr 2026 08:00:23 -0500
Subject: [PATCH] ipmi:ssif: Clean up kthread on errors

If an error occurs after the ssif kthread is created, but before the
main IPMI code starts the ssif interface, the ssif kthread will not
be stopped.

So make sure the kthread is stopped on an error condition if it is
running.

Fixes: 259307074bfc ("ipmi: Add SMBus interface driver (SSIF)")
Reported-by: Li Xiao <<252270051@hdu.edu.cn>
Cc: stable@vger.kernel.org
Reviewed-by: Li Xiao <252270051@hdu.edu.cn>
Signed-off-by: Corey Minyard <corey@minyard.net>

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index ce918fe987c6..b49500a1bd36 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -1268,8 +1268,10 @@ static void shutdown_ssif(void *send_info)
 	ssif_info->stopping = true;
 	timer_delete_sync(&ssif_info->watch_timer);
 	timer_delete_sync(&ssif_info->retry_timer);
-	if (ssif_info->thread)
+	if (ssif_info->thread) {
 		kthread_stop(ssif_info->thread);
+		ssif_info->thread = NULL;
+	}
 }
 
 static void ssif_remove(struct i2c_client *client)
@@ -1912,6 +1914,15 @@ static int ssif_probe(struct i2c_client *client)
 
  out:
 	if (rv) {
+		/*
+		 * If ipmi_register_smi() starts the interface, it will
+		 * call shutdown and that will free the thread and set
+		 * it to NULL.  Otherwise it must be freed here.
+		 */
+		if (ssif_info->thread) {
+			kthread_stop(ssif_info->thread);
+			ssif_info->thread = NULL;
+		}
 		if (addr_info)
 			addr_info->client = NULL;
 


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 6.12.y 1/2] ipmi:ssif: Fix a shutdown race
  2026-05-01 10:58 FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 6.12-stable tree gregkh
@ 2026-05-01 13:56 ` Corey Minyard
  2026-05-01 13:56   ` [PATCH 6.12.y 2/2] ipmi:ssif: Clean up kthread on errors Corey Minyard
  2026-05-03 18:19   ` [PATCH 6.12.y/6.6.y/6.1.y/5.15.y/5.10.y 1-2/2] ipmi:ssif: shutdown race + kthread cleanup Sasha Levin
  0 siblings, 2 replies; 19+ messages in thread
From: Corey Minyard @ 2026-05-01 13:56 UTC (permalink / raw)
  To: stable; +Cc: Corey Minyard, Corey Minyard

It was possible for the SSIF thread to stop and quit before the
kthread_stop() call because ssif->stopping was set before the
stop.  So only exit the SSIF thread is kthread_should_stop()
returns true.

There is no need to wake the thread, as the wait will be interrupted
by kthread_stop().

Signed-off-by: Corey Minyard <cminyard@mvista.com>
(cherry picked from commit 6bd0eb6d759b9a22c5509ea04e19c2e8407ba418)
---
 drivers/char/ipmi/ipmi_ssif.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index d04b391048fb..cce4d9c00566 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -481,8 +481,6 @@ static int ipmi_ssif_thread(void *data)
 		/* Wait for something to do */
 		result = wait_for_completion_interruptible(
 						&ssif_info->wake_thread);
-		if (ssif_info->stopping)
-			break;
 		if (result == -ERESTARTSYS)
 			continue;
 		init_completion(&ssif_info->wake_thread);
@@ -1270,10 +1268,8 @@ static void shutdown_ssif(void *send_info)
 	ssif_info->stopping = true;
 	del_timer_sync(&ssif_info->watch_timer);
 	del_timer_sync(&ssif_info->retry_timer);
-	if (ssif_info->thread) {
-		complete(&ssif_info->wake_thread);
+	if (ssif_info->thread)
 		kthread_stop(ssif_info->thread);
-	}
 }
 
 static void ssif_remove(struct i2c_client *client)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 6.12.y 2/2] ipmi:ssif: Clean up kthread on errors
  2026-05-01 13:56 ` [PATCH 6.12.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
@ 2026-05-01 13:56   ` Corey Minyard
  2026-05-03 18:19   ` [PATCH 6.12.y/6.6.y/6.1.y/5.15.y/5.10.y 1-2/2] ipmi:ssif: shutdown race + kthread cleanup Sasha Levin
  1 sibling, 0 replies; 19+ messages in thread
From: Corey Minyard @ 2026-05-01 13:56 UTC (permalink / raw)
  To: stable; +Cc: Corey Minyard, Li Xiao

If an error occurs after the ssif kthread is created, but before the
main IPMI code starts the ssif interface, the ssif kthread will not
be stopped.

So make sure the kthread is stopped on an error condition if it is
running.

Fixes: 259307074bfc ("ipmi: Add SMBus interface driver (SSIF)")
Reported-by: Li Xiao <<252270051@hdu.edu.cn>
Cc: stable@vger.kernel.org
Reviewed-by: Li Xiao <252270051@hdu.edu.cn>
Signed-off-by: Corey Minyard <corey@minyard.net>
(cherry picked from commit 75c486cb1bcaa1a3ec3a6438498176a3a4998ae4)
---
 drivers/char/ipmi/ipmi_ssif.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index cce4d9c00566..347446b165a9 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -1268,8 +1268,10 @@ static void shutdown_ssif(void *send_info)
 	ssif_info->stopping = true;
 	del_timer_sync(&ssif_info->watch_timer);
 	del_timer_sync(&ssif_info->retry_timer);
-	if (ssif_info->thread)
+	if (ssif_info->thread) {
 		kthread_stop(ssif_info->thread);
+		ssif_info->thread = NULL;
+	}
 }
 
 static void ssif_remove(struct i2c_client *client)
@@ -1916,6 +1918,15 @@ static int ssif_probe(struct i2c_client *client)
 
  out:
 	if (rv) {
+		/*
+		 * If ipmi_register_smi() starts the interface, it will
+		 * call shutdown and that will free the thread and set
+		 * it to NULL.  Otherwise it must be freed here.
+		 */
+		if (ssif_info->thread) {
+			kthread_stop(ssif_info->thread);
+			ssif_info->thread = NULL;
+		}
 		if (addr_info)
 			addr_info->client = NULL;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 6.6.y 1/2] ipmi:ssif: Fix a shutdown race
  2026-05-01 10:58 FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 6.6-stable tree gregkh
@ 2026-05-01 14:06 ` Corey Minyard
  2026-05-01 14:06   ` [PATCH 6.6.y 2/2] ipmi:ssif: Clean up kthread on errors Corey Minyard
  0 siblings, 1 reply; 19+ messages in thread
From: Corey Minyard @ 2026-05-01 14:06 UTC (permalink / raw)
  To: stable; +Cc: Corey Minyard, Corey Minyard

It was possible for the SSIF thread to stop and quit before the
kthread_stop() call because ssif->stopping was set before the
stop.  So only exit the SSIF thread is kthread_should_stop()
returns true.

There is no need to wake the thread, as the wait will be interrupted
by kthread_stop().

Signed-off-by: Corey Minyard <cminyard@mvista.com>
(cherry picked from commit 6bd0eb6d759b9a22c5509ea04e19c2e8407ba418)
---
 drivers/char/ipmi/ipmi_ssif.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index df8dd50b4cbe..3c4aa87d6bd4 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -481,8 +481,6 @@ static int ipmi_ssif_thread(void *data)
 		/* Wait for something to do */
 		result = wait_for_completion_interruptible(
 						&ssif_info->wake_thread);
-		if (ssif_info->stopping)
-			break;
 		if (result == -ERESTARTSYS)
 			continue;
 		init_completion(&ssif_info->wake_thread);
@@ -1270,10 +1268,8 @@ static void shutdown_ssif(void *send_info)
 	ssif_info->stopping = true;
 	del_timer_sync(&ssif_info->watch_timer);
 	del_timer_sync(&ssif_info->retry_timer);
-	if (ssif_info->thread) {
-		complete(&ssif_info->wake_thread);
+	if (ssif_info->thread)
 		kthread_stop(ssif_info->thread);
-	}
 }
 
 static void ssif_remove(struct i2c_client *client)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 6.6.y 2/2] ipmi:ssif: Clean up kthread on errors
  2026-05-01 14:06 ` [PATCH 6.6.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
@ 2026-05-01 14:06   ` Corey Minyard
  0 siblings, 0 replies; 19+ messages in thread
From: Corey Minyard @ 2026-05-01 14:06 UTC (permalink / raw)
  To: stable; +Cc: Corey Minyard, Li Xiao

If an error occurs after the ssif kthread is created, but before the
main IPMI code starts the ssif interface, the ssif kthread will not
be stopped.

So make sure the kthread is stopped on an error condition if it is
running.

Fixes: 259307074bfc ("ipmi: Add SMBus interface driver (SSIF)")
Reported-by: Li Xiao <<252270051@hdu.edu.cn>
Cc: stable@vger.kernel.org
Reviewed-by: Li Xiao <252270051@hdu.edu.cn>
Signed-off-by: Corey Minyard <corey@minyard.net>
(cherry picked from commit 75c486cb1bcaa1a3ec3a6438498176a3a4998ae4)
---
 drivers/char/ipmi/ipmi_ssif.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index 3c4aa87d6bd4..6665cf1891b8 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -1268,8 +1268,10 @@ static void shutdown_ssif(void *send_info)
 	ssif_info->stopping = true;
 	del_timer_sync(&ssif_info->watch_timer);
 	del_timer_sync(&ssif_info->retry_timer);
-	if (ssif_info->thread)
+	if (ssif_info->thread) {
 		kthread_stop(ssif_info->thread);
+		ssif_info->thread = NULL;
+	}
 }
 
 static void ssif_remove(struct i2c_client *client)
@@ -1894,6 +1896,15 @@ static int ssif_probe(struct i2c_client *client)
 
  out:
 	if (rv) {
+		/*
+		 * If ipmi_register_smi() starts the interface, it will
+		 * call shutdown and that will free the thread and set
+		 * it to NULL.  Otherwise it must be freed here.
+		 */
+		if (ssif_info->thread) {
+			kthread_stop(ssif_info->thread);
+			ssif_info->thread = NULL;
+		}
 		if (addr_info)
 			addr_info->client = NULL;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 6.1.y 1/2] ipmi:ssif: Fix a shutdown race
  2026-05-01 10:58 FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 6.1-stable tree gregkh
@ 2026-05-01 14:19 ` Corey Minyard
  2026-05-01 14:19   ` [PATCH 6.1.y 2/2] ipmi:ssif: Clean up kthread on errors Corey Minyard
  0 siblings, 1 reply; 19+ messages in thread
From: Corey Minyard @ 2026-05-01 14:19 UTC (permalink / raw)
  To: stable; +Cc: Corey Minyard, Corey Minyard

It was possible for the SSIF thread to stop and quit before the
kthread_stop() call because ssif->stopping was set before the
stop.  So only exit the SSIF thread is kthread_should_stop()
returns true.

There is no need to wake the thread, as the wait will be interrupted
by kthread_stop().

Signed-off-by: Corey Minyard <cminyard@mvista.com>
(cherry picked from commit 6bd0eb6d759b9a22c5509ea04e19c2e8407ba418)
---
 drivers/char/ipmi/ipmi_ssif.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index 248459f97c67..fbc870ffff6a 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -481,8 +481,6 @@ static int ipmi_ssif_thread(void *data)
 		/* Wait for something to do */
 		result = wait_for_completion_interruptible(
 						&ssif_info->wake_thread);
-		if (ssif_info->stopping)
-			break;
 		if (result == -ERESTARTSYS)
 			continue;
 		init_completion(&ssif_info->wake_thread);
@@ -1270,10 +1268,8 @@ static void shutdown_ssif(void *send_info)
 	ssif_info->stopping = true;
 	del_timer_sync(&ssif_info->watch_timer);
 	del_timer_sync(&ssif_info->retry_timer);
-	if (ssif_info->thread) {
-		complete(&ssif_info->wake_thread);
+	if (ssif_info->thread)
 		kthread_stop(ssif_info->thread);
-	}
 }
 
 static void ssif_remove(struct i2c_client *client)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 6.1.y 2/2] ipmi:ssif: Clean up kthread on errors
  2026-05-01 14:19 ` [PATCH 6.1.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
@ 2026-05-01 14:19   ` Corey Minyard
  0 siblings, 0 replies; 19+ messages in thread
From: Corey Minyard @ 2026-05-01 14:19 UTC (permalink / raw)
  To: stable; +Cc: Corey Minyard, Li Xiao

If an error occurs after the ssif kthread is created, but before the
main IPMI code starts the ssif interface, the ssif kthread will not
be stopped.

So make sure the kthread is stopped on an error condition if it is
running.

Fixes: 259307074bfc ("ipmi: Add SMBus interface driver (SSIF)")
Reported-by: Li Xiao <<252270051@hdu.edu.cn>
Cc: stable@vger.kernel.org
Reviewed-by: Li Xiao <252270051@hdu.edu.cn>
Signed-off-by: Corey Minyard <corey@minyard.net>
(cherry picked from commit 75c486cb1bcaa1a3ec3a6438498176a3a4998ae4)
---
 drivers/char/ipmi/ipmi_ssif.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index fbc870ffff6a..4d68c7a451ba 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -1268,8 +1268,10 @@ static void shutdown_ssif(void *send_info)
 	ssif_info->stopping = true;
 	del_timer_sync(&ssif_info->watch_timer);
 	del_timer_sync(&ssif_info->retry_timer);
-	if (ssif_info->thread)
+	if (ssif_info->thread) {
 		kthread_stop(ssif_info->thread);
+		ssif_info->thread = NULL;
+	}
 }
 
 static void ssif_remove(struct i2c_client *client)
@@ -1897,6 +1899,15 @@ static int ssif_probe(struct i2c_client *client)
 
  out:
 	if (rv) {
+		/*
+		 * If ipmi_register_smi() starts the interface, it will
+		 * call shutdown and that will free the thread and set
+		 * it to NULL.  Otherwise it must be freed here.
+		 */
+		if (ssif_info->thread) {
+			kthread_stop(ssif_info->thread);
+			ssif_info->thread = NULL;
+		}
 		if (addr_info)
 			addr_info->client = NULL;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 5.15.y 1/2] ipmi:ssif: Fix a shutdown race
  2026-05-01 10:58 FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 5.15-stable tree gregkh
@ 2026-05-01 14:27 ` Corey Minyard
  2026-05-01 14:27   ` [PATCH 5.15.y 2/2] ipmi:ssif: Clean up kthread on errors Corey Minyard
  2026-05-01 16:11 ` [PATCH 5.15.y] ipmi:ssif: Fix a thread shutdown issue Corey Minyard
  1 sibling, 1 reply; 19+ messages in thread
From: Corey Minyard @ 2026-05-01 14:27 UTC (permalink / raw)
  To: stable; +Cc: Corey Minyard, Corey Minyard

It was possible for the SSIF thread to stop and quit before the
kthread_stop() call because ssif->stopping was set before the
stop.  So only exit the SSIF thread is kthread_should_stop()
returns true.

There is no need to wake the thread, as the wait will be interrupted
by kthread_stop().

Signed-off-by: Corey Minyard <cminyard@mvista.com>
(cherry picked from commit 6bd0eb6d759b9a22c5509ea04e19c2e8407ba418)
---
 drivers/char/ipmi/ipmi_ssif.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index 30f757249c5c..22074f23c06a 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -487,8 +487,6 @@ static int ipmi_ssif_thread(void *data)
 		/* Wait for something to do */
 		result = wait_for_completion_interruptible(
 						&ssif_info->wake_thread);
-		if (ssif_info->stopping)
-			break;
 		if (result == -ERESTARTSYS)
 			continue;
 		init_completion(&ssif_info->wake_thread);
@@ -1279,10 +1277,8 @@ static void shutdown_ssif(void *send_info)
 	ssif_info->stopping = true;
 	del_timer_sync(&ssif_info->watch_timer);
 	del_timer_sync(&ssif_info->retry_timer);
-	if (ssif_info->thread) {
-		complete(&ssif_info->wake_thread);
+	if (ssif_info->thread)
 		kthread_stop(ssif_info->thread);
-	}
 }
 
 static int ssif_remove(struct i2c_client *client)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 5.15.y 2/2] ipmi:ssif: Clean up kthread on errors
  2026-05-01 14:27 ` [PATCH 5.15.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
@ 2026-05-01 14:27   ` Corey Minyard
  0 siblings, 0 replies; 19+ messages in thread
From: Corey Minyard @ 2026-05-01 14:27 UTC (permalink / raw)
  To: stable; +Cc: Corey Minyard, Li Xiao

If an error occurs after the ssif kthread is created, but before the
main IPMI code starts the ssif interface, the ssif kthread will not
be stopped.

So make sure the kthread is stopped on an error condition if it is
running.

Fixes: 259307074bfc ("ipmi: Add SMBus interface driver (SSIF)")
Reported-by: Li Xiao <<252270051@hdu.edu.cn>
Cc: stable@vger.kernel.org
Reviewed-by: Li Xiao <252270051@hdu.edu.cn>
Signed-off-by: Corey Minyard <corey@minyard.net>
(cherry picked from commit 75c486cb1bcaa1a3ec3a6438498176a3a4998ae4)
---
 drivers/char/ipmi/ipmi_ssif.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index 22074f23c06a..ce0f20cac88d 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -1277,8 +1277,10 @@ static void shutdown_ssif(void *send_info)
 	ssif_info->stopping = true;
 	del_timer_sync(&ssif_info->watch_timer);
 	del_timer_sync(&ssif_info->retry_timer);
-	if (ssif_info->thread)
+	if (ssif_info->thread) {
 		kthread_stop(ssif_info->thread);
+		ssif_info->thread = NULL;
+	}
 }
 
 static int ssif_remove(struct i2c_client *client)
@@ -1908,6 +1910,15 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
 
  out:
 	if (rv) {
+		/*
+		 * If ipmi_register_smi() starts the interface, it will
+		 * call shutdown and that will free the thread and set
+		 * it to NULL.  Otherwise it must be freed here.
+		 */
+		if (ssif_info->thread) {
+			kthread_stop(ssif_info->thread);
+			ssif_info->thread = NULL;
+		}
 		if (addr_info)
 			addr_info->client = NULL;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 5.10.y 1/2] ipmi:ssif: Fix a shutdown race
  2026-05-01 10:58 FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 5.10-stable tree gregkh
@ 2026-05-01 14:54 ` Corey Minyard
  2026-05-01 14:54   ` [PATCH 5.10.y 2/2] ipmi:ssif: Clean up kthread on errors Corey Minyard
  2026-05-01 16:20 ` [PATCH 5.10.y] ipmi:ssif: Fix a thread shutdown issue Corey Minyard
  1 sibling, 1 reply; 19+ messages in thread
From: Corey Minyard @ 2026-05-01 14:54 UTC (permalink / raw)
  To: stable; +Cc: Corey Minyard, Corey Minyard

It was possible for the SSIF thread to stop and quit before the
kthread_stop() call because ssif->stopping was set before the
stop.  So only exit the SSIF thread is kthread_should_stop()
returns true.

There is no need to wake the thread, as the wait will be interrupted
by kthread_stop().

Signed-off-by: Corey Minyard <cminyard@mvista.com>
(cherry picked from commit 6bd0eb6d759b9a22c5509ea04e19c2e8407ba418)
---
 drivers/char/ipmi/ipmi_ssif.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index 30f757249c5c..22074f23c06a 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -487,8 +487,6 @@ static int ipmi_ssif_thread(void *data)
 		/* Wait for something to do */
 		result = wait_for_completion_interruptible(
 						&ssif_info->wake_thread);
-		if (ssif_info->stopping)
-			break;
 		if (result == -ERESTARTSYS)
 			continue;
 		init_completion(&ssif_info->wake_thread);
@@ -1279,10 +1277,8 @@ static void shutdown_ssif(void *send_info)
 	ssif_info->stopping = true;
 	del_timer_sync(&ssif_info->watch_timer);
 	del_timer_sync(&ssif_info->retry_timer);
-	if (ssif_info->thread) {
-		complete(&ssif_info->wake_thread);
+	if (ssif_info->thread)
 		kthread_stop(ssif_info->thread);
-	}
 }
 
 static int ssif_remove(struct i2c_client *client)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 5.10.y 2/2] ipmi:ssif: Clean up kthread on errors
  2026-05-01 14:54 ` [PATCH 5.10.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
@ 2026-05-01 14:54   ` Corey Minyard
  0 siblings, 0 replies; 19+ messages in thread
From: Corey Minyard @ 2026-05-01 14:54 UTC (permalink / raw)
  To: stable; +Cc: Corey Minyard, Li Xiao

If an error occurs after the ssif kthread is created, but before the
main IPMI code starts the ssif interface, the ssif kthread will not
be stopped.

So make sure the kthread is stopped on an error condition if it is
running.

Fixes: 259307074bfc ("ipmi: Add SMBus interface driver (SSIF)")
Reported-by: Li Xiao <<252270051@hdu.edu.cn>
Cc: stable@vger.kernel.org
Reviewed-by: Li Xiao <252270051@hdu.edu.cn>
Signed-off-by: Corey Minyard <corey@minyard.net>
(cherry picked from commit 75c486cb1bcaa1a3ec3a6438498176a3a4998ae4)
---
 drivers/char/ipmi/ipmi_ssif.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index 22074f23c06a..ce0f20cac88d 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -1277,8 +1277,10 @@ static void shutdown_ssif(void *send_info)
 	ssif_info->stopping = true;
 	del_timer_sync(&ssif_info->watch_timer);
 	del_timer_sync(&ssif_info->retry_timer);
-	if (ssif_info->thread)
+	if (ssif_info->thread) {
 		kthread_stop(ssif_info->thread);
+		ssif_info->thread = NULL;
+	}
 }
 
 static int ssif_remove(struct i2c_client *client)
@@ -1908,6 +1910,15 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
 
  out:
 	if (rv) {
+		/*
+		 * If ipmi_register_smi() starts the interface, it will
+		 * call shutdown and that will free the thread and set
+		 * it to NULL.  Otherwise it must be freed here.
+		 */
+		if (ssif_info->thread) {
+			kthread_stop(ssif_info->thread);
+			ssif_info->thread = NULL;
+		}
 		if (addr_info)
 			addr_info->client = NULL;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 5.15.y] ipmi:ssif: Fix a thread shutdown issue
  2026-05-01 10:58 FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 5.15-stable tree gregkh
  2026-05-01 14:27 ` [PATCH 5.15.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
@ 2026-05-01 16:11 ` Corey Minyard
  1 sibling, 0 replies; 19+ messages in thread
From: Corey Minyard @ 2026-05-01 16:11 UTC (permalink / raw)
  To: stable; +Cc: Corey Minyard

The kthread used by ssif had a shutdown issue that was fixed by
6bd0eb6d759b ("ipmi:ssif: Fix a shutdown race").  That was backported to
an older kernel in the process of fixing another issue,
2105b70be84d ("ipmi:ssif: Clean up kthread on errors") as it would
not have worked correctly without the shutdown race fix.

Kernel version 6.1 has a fix to kthread stop to cause interruptible
waits to return -ERESTARTSYS on a stop.  This has not been backported
to older kernels, and that would probably be a bad idea.  But not
having this means that the completion in the SSIF driver will
not wake up on kthread_stop(), thus the driver hangs on unload.

We can't cause the interrupt before calling kthread_stop() because
the task stop bit need to be set before causing the interrupt.

So re-introduce the code removed by 6bd0eb6d759b ("ipmi:ssif: Fix a
shutdown race") but add a wait at the end of the thread so it
doesn't exit until kthread_should_stop() is set.

Fixes: 6bd0eb6d759b ("ipmi:ssif: Fix a shutdown race")
Signed-off-by: Corey Minyard <corey@minyard.net>
---
I realized I hadn't done an unload test on this on the older kernels.
But why wouldn't that work?  Well, it didn't.  One more patch for this
on top of the previous two.  Sorry :(.


 drivers/char/ipmi/ipmi_ssif.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index ce0f20cac88d..b884bfae7fa6 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -487,6 +487,8 @@ static int ipmi_ssif_thread(void *data)
 		/* Wait for something to do */
 		result = wait_for_completion_interruptible(
 						&ssif_info->wake_thread);
+		if (ssif_info->stopping)
+			break;
 		if (result == -ERESTARTSYS)
 			continue;
 		init_completion(&ssif_info->wake_thread);
@@ -511,6 +513,16 @@ static int ipmi_ssif_thread(void *data)
 		}
 	}
 
+	/*
+	 * The thread can break out of the loop if stopping is set,
+	 * and this can be before kthread_stop() gets called and thus
+	 * kthread_should_stop() will not be set.  This can cause
+	 * spinning calling this function and other bad things.  So
+	 * wait for kthread_should_stop() to be set.
+	 */
+	while (!kthread_should_stop())
+		msleep_interruptible(1);
+
 	return 0;
 }
 
@@ -1278,6 +1290,7 @@ static void shutdown_ssif(void *send_info)
 	del_timer_sync(&ssif_info->watch_timer);
 	del_timer_sync(&ssif_info->retry_timer);
 	if (ssif_info->thread) {
+		complete(&ssif_info->wake_thread);
 		kthread_stop(ssif_info->thread);
 		ssif_info->thread = NULL;
 	}
@@ -1916,6 +1929,8 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
 		 * it to NULL.  Otherwise it must be freed here.
 		 */
 		if (ssif_info->thread) {
+			ssif_info->stopping = true;
+			complete(&ssif_info->wake_thread);
 			kthread_stop(ssif_info->thread);
 			ssif_info->thread = NULL;
 		}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 5.10.y] ipmi:ssif: Fix a thread shutdown issue
  2026-05-01 10:58 FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 5.10-stable tree gregkh
  2026-05-01 14:54 ` [PATCH 5.10.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
@ 2026-05-01 16:20 ` Corey Minyard
  1 sibling, 0 replies; 19+ messages in thread
From: Corey Minyard @ 2026-05-01 16:20 UTC (permalink / raw)
  To: stable; +Cc: Corey Minyard

The kthread used by ssif had a shutdown issue that was fixed by
6bd0eb6d759b ("ipmi:ssif: Fix a shutdown race").  That was backported to
an older kernel in the process of fixing another issue,
2105b70be84d ("ipmi:ssif: Clean up kthread on errors") as it would
not have worked correctly without the shutdown race fix.

Kernel version 6.1 has a fix to kthread stop to cause interruptible
waits to return -ERESTARTSYS on a stop.  This has not been backported
to older kernels, and that would probably be a bad idea.  But not
having this means that the completion in the SSIF driver will
not wake up on kthread_stop(), thus the driver hangs on unload.

We can't cause the interrupt before calling kthread_stop() because
the task stop bit need to be set before causing the interrupt.

So re-introduce the code removed by 6bd0eb6d759b ("ipmi:ssif: Fix a
shutdown race") but add a wait at the end of the thread so it
doesn't exit until kthread_should_stop() is set.

Fixes: 6bd0eb6d759b ("ipmi:ssif: Fix a shutdown race")
Signed-off-by: Corey Minyard <corey@minyard.net>
---
I realized I hadn't done an unload test on this on the older kernels.
But why wouldn't that work?  Well, it didn't.  One more patch for this
on top of the previous two.  Sorry :(.

 drivers/char/ipmi/ipmi_ssif.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index ce0f20cac88d..b884bfae7fa6 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -487,6 +487,8 @@ static int ipmi_ssif_thread(void *data)
 		/* Wait for something to do */
 		result = wait_for_completion_interruptible(
 						&ssif_info->wake_thread);
+		if (ssif_info->stopping)
+			break;
 		if (result == -ERESTARTSYS)
 			continue;
 		init_completion(&ssif_info->wake_thread);
@@ -511,6 +513,16 @@ static int ipmi_ssif_thread(void *data)
 		}
 	}
 
+	/*
+	 * The thread can break out of the loop if stopping is set,
+	 * and this can be before kthread_stop() gets called and thus
+	 * kthread_should_stop() will not be set.  This can cause
+	 * spinning calling this function and other bad things.  So
+	 * wait for kthread_should_stop() to be set.
+	 */
+	while (!kthread_should_stop())
+		msleep_interruptible(1);
+
 	return 0;
 }
 
@@ -1278,6 +1290,7 @@ static void shutdown_ssif(void *send_info)
 	del_timer_sync(&ssif_info->watch_timer);
 	del_timer_sync(&ssif_info->retry_timer);
 	if (ssif_info->thread) {
+		complete(&ssif_info->wake_thread);
 		kthread_stop(ssif_info->thread);
 		ssif_info->thread = NULL;
 	}
@@ -1916,6 +1929,8 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
 		 * it to NULL.  Otherwise it must be freed here.
 		 */
 		if (ssif_info->thread) {
+			ssif_info->stopping = true;
+			complete(&ssif_info->wake_thread);
 			kthread_stop(ssif_info->thread);
 			ssif_info->thread = NULL;
 		}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH 6.12.y/6.6.y/6.1.y/5.15.y/5.10.y 1-2/2] ipmi:ssif: shutdown race + kthread cleanup
  2026-05-01 13:56 ` [PATCH 6.12.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
  2026-05-01 13:56   ` [PATCH 6.12.y 2/2] ipmi:ssif: Clean up kthread on errors Corey Minyard
@ 2026-05-03 18:19   ` Sasha Levin
  2026-05-04 11:04     ` Corey Minyard
  1 sibling, 1 reply; 19+ messages in thread
From: Sasha Levin @ 2026-05-03 18:19 UTC (permalink / raw)
  To: Corey Minyard; +Cc: Corey Minyard, stable

Hi Corey,

I queued the 2-patch series across 6.12.y / 6.6.y / 6.1.y / 5.15.y /
5.10.y but had to drop them all again before pushing to stable-queue.

Patch 2/2 (cherry-pick of upstream 75c486cb1bca, "ipmi:ssif: Clean up
kthread on errors") has a real bug in upstream itself: in ssif_probe()'s
out: label,

	if (ssif_info->thread)
		kthread_stop(ssif_info->thread);

runs even when kthread_run() failed, in which case ssif_info->thread is
an ERR_PTR rather than NULL, so kthread_stop() ends up being called on
an error pointer. The check needs to be IS_ERR_OR_NULL(), or
ssif_info->thread needs to be reset to NULL on the kthread_run() error
path before goto out.

The same upstream bug propagates to all five LTS submissions, so I had
to drop them all rather than just the older trees. Could you send a
fixed version (an upstream follow-up that flips through the LTS trees
would be ideal)?

For 5.15 and 5.10 specifically, I'd also like to fold in your standalone
"ipmi:ssif: Fix a thread shutdown issue" follow-up
(<20260501161407.1106914-1-corey@minyard.net> for 5.15,
<20260501162131.1165570-1-corey@minyard.net> for 5.10) when you resend.
Those branches lack the kthread_stop ERESTARTSYS behaviour that 6.1+
has, and your follow-up addresses exactly that. A 3-patch series for
5.15/5.10 (plus the 2-patch series for 6.12/6.6/6.1) with the ERR_PTR
fix folded in would let me requeue the whole set in one pass.

--
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 6.12.y/6.6.y/6.1.y/5.15.y/5.10.y 1-2/2] ipmi:ssif: shutdown race + kthread cleanup
  2026-05-03 18:19   ` [PATCH 6.12.y/6.6.y/6.1.y/5.15.y/5.10.y 1-2/2] ipmi:ssif: shutdown race + kthread cleanup Sasha Levin
@ 2026-05-04 11:04     ` Corey Minyard
  0 siblings, 0 replies; 19+ messages in thread
From: Corey Minyard @ 2026-05-04 11:04 UTC (permalink / raw)
  To: Sasha Levin; +Cc: Corey Minyard, stable

On Sun, May 03, 2026 at 02:19:56PM -0400, Sasha Levin wrote:
> Hi Corey,
> 
> I queued the 2-patch series across 6.12.y / 6.6.y / 6.1.y / 5.15.y /
> 5.10.y but had to drop them all again before pushing to stable-queue.
> 
> Patch 2/2 (cherry-pick of upstream 75c486cb1bca, "ipmi:ssif: Clean up
> kthread on errors") has a real bug in upstream itself: in ssif_probe()'s
> out: label,
> 
> 	if (ssif_info->thread)
> 		kthread_stop(ssif_info->thread);
> 
> runs even when kthread_run() failed, in which case ssif_info->thread is
> an ERR_PTR rather than NULL, so kthread_stop() ends up being called on
> an error pointer. The check needs to be IS_ERR_OR_NULL(), or
> ssif_info->thread needs to be reset to NULL on the kthread_run() error
> path before goto out.
> 
> The same upstream bug propagates to all five LTS submissions, so I had
> to drop them all rather than just the older trees. Could you send a
> fixed version (an upstream follow-up that flips through the LTS trees
> would be ideal)?

There is already a fix for this queued in the next tree that I was about
to submit.  Fixing it here would add to the confusion.

> 
> For 5.15 and 5.10 specifically, I'd also like to fold in your standalone
> "ipmi:ssif: Fix a thread shutdown issue" follow-up
> (<20260501161407.1106914-1-corey@minyard.net> for 5.15,
> <20260501162131.1165570-1-corey@minyard.net> for 5.10) when you resend.
> Those branches lack the kthread_stop ERESTARTSYS behaviour that 6.1+
> has, and your follow-up addresses exactly that. A 3-patch series for
> 5.15/5.10 (plus the 2-patch series for 6.12/6.6/6.1) with the ERR_PTR
> fix folded in would let me requeue the whole set in one pass.

Ok, I'll fold that in to 5.10 and 5.15 as you request, that makes sense.

Can you add the 6.1/6.6/6.12 ones as they are and I'll submit the queue
to fix I have to Linus?

-corey

> 
> --
> Thanks,
> Sasha

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2026-05-04 11:04 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-01 10:58 FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 6.12-stable tree gregkh
2026-05-01 13:56 ` [PATCH 6.12.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
2026-05-01 13:56   ` [PATCH 6.12.y 2/2] ipmi:ssif: Clean up kthread on errors Corey Minyard
2026-05-03 18:19   ` [PATCH 6.12.y/6.6.y/6.1.y/5.15.y/5.10.y 1-2/2] ipmi:ssif: shutdown race + kthread cleanup Sasha Levin
2026-05-04 11:04     ` Corey Minyard
  -- strict thread matches above, loose matches on Subject: below --
2026-05-01 10:58 FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 6.1-stable tree gregkh
2026-05-01 14:19 ` [PATCH 6.1.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
2026-05-01 14:19   ` [PATCH 6.1.y 2/2] ipmi:ssif: Clean up kthread on errors Corey Minyard
2026-05-01 10:58 FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 6.6-stable tree gregkh
2026-05-01 14:06 ` [PATCH 6.6.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
2026-05-01 14:06   ` [PATCH 6.6.y 2/2] ipmi:ssif: Clean up kthread on errors Corey Minyard
2026-05-01 10:58 FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 5.15-stable tree gregkh
2026-05-01 14:27 ` [PATCH 5.15.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
2026-05-01 14:27   ` [PATCH 5.15.y 2/2] ipmi:ssif: Clean up kthread on errors Corey Minyard
2026-05-01 16:11 ` [PATCH 5.15.y] ipmi:ssif: Fix a thread shutdown issue Corey Minyard
2026-05-01 10:58 FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 5.10-stable tree gregkh
2026-05-01 14:54 ` [PATCH 5.10.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
2026-05-01 14:54   ` [PATCH 5.10.y 2/2] ipmi:ssif: Clean up kthread on errors Corey Minyard
2026-05-01 16:20 ` [PATCH 5.10.y] ipmi:ssif: Fix a thread shutdown issue Corey Minyard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox