6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Corey Minyard [ Upstream commit 75c486cb1bcaa1a3ec3a6438498176a3a4998ae4 ] 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 Signed-off-by: Sasha Levin --- drivers/char/ipmi/ipmi_ssif.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c index 7950f13c1ef76..a19184151323c 100644 --- a/drivers/char/ipmi/ipmi_ssif.c +++ b/drivers/char/ipmi/ipmi_ssif.c @@ -1292,6 +1292,7 @@ static void shutdown_ssif(void *send_info) if (ssif_info->thread) { complete(&ssif_info->wake_thread); kthread_stop(ssif_info->thread); + ssif_info->thread = NULL; } } @@ -1936,6 +1937,25 @@ 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) { + struct task_struct *thread = ssif_info->thread; + + /* + * The thread exits on its own once it sees + * stopping, so hold a reference across the stop. + */ + get_task_struct(thread); + ssif_info->stopping = true; + complete(&ssif_info->wake_thread); + kthread_stop(thread); + put_task_struct(thread); + ssif_info->thread = NULL; + } if (addr_info) addr_info->client = NULL; -- 2.53.0