| 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: ipmi:ssif: Clean up kthread on errors |
| |
| From: Corey Minyard <corey@minyard.net> |
| |
| commit 75c486cb1bcaa1a3ec3a6438498176a3a4998ae4 upstream. |
| |
| 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> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| --- |
| drivers/char/ipmi/ipmi_ssif.c | 13 ++++++++++++- |
| 1 file changed, 12 insertions(+), 1 deletion(-) |
| |
| --- a/drivers/char/ipmi/ipmi_ssif.c |
| +++ b/drivers/char/ipmi/ipmi_ssif.c |
| @@ -1268,8 +1268,10 @@ static void shutdown_ssif(void *send_inf |
| 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) |
| @@ -1916,6 +1918,15 @@ static int ssif_probe(struct i2c_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; |
| |