Skip to content

Commit 75c486c

Browse files
committed
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: 2593070 ("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>
1 parent 91eb7ec commit 75c486c

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

drivers/char/ipmi/ipmi_ssif.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1268,8 +1268,10 @@ static void shutdown_ssif(void *send_info)
12681268
ssif_info->stopping = true;
12691269
timer_delete_sync(&ssif_info->watch_timer);
12701270
timer_delete_sync(&ssif_info->retry_timer);
1271-
if (ssif_info->thread)
1271+
if (ssif_info->thread) {
12721272
kthread_stop(ssif_info->thread);
1273+
ssif_info->thread = NULL;
1274+
}
12731275
}
12741276

12751277
static void ssif_remove(struct i2c_client *client)
@@ -1912,6 +1914,15 @@ static int ssif_probe(struct i2c_client *client)
19121914

19131915
out:
19141916
if (rv) {
1917+
/*
1918+
* If ipmi_register_smi() starts the interface, it will
1919+
* call shutdown and that will free the thread and set
1920+
* it to NULL. Otherwise it must be freed here.
1921+
*/
1922+
if (ssif_info->thread) {
1923+
kthread_stop(ssif_info->thread);
1924+
ssif_info->thread = NULL;
1925+
}
19151926
if (addr_info)
19161927
addr_info->client = NULL;
19171928

0 commit comments

Comments
 (0)