staging: pi433: Return thread immediately when kthread_should_stop() call.
authorSidong Yang <realwakka@gmail.com>
Tue, 2 Apr 2019 12:14:31 +0000 (12:14 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 2 Apr 2019 17:58:04 +0000 (19:58 +0200)
When kthread_stop() called by removing module, running thread should
return immediately. Otherwise, It is very dangerous that thread may access
any released data like struct pi433_device.

Signed-off-by: Sidong Yang <realwakka@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/pi433/pi433_if.c

index ab90d6f80931816c77888ed691adcb6fdafd92c8..16dc380eb1762cc9b62ac4c04c25a715d2d85a35 100644 (file)
@@ -736,7 +736,7 @@ pi433_tx_thread(void *data)
                                         device->free_in_fifo == FIFO_SIZE ||
                                         kthread_should_stop());
                if (kthread_should_stop())
-                       dev_dbg(device->dev, "ABORT\n");
+                       return 0;
 
                /* STOP_TRANSMISSION */
                dev_dbg(device->dev, "thread: Packet sent. Set mode to stby.");