aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/usbip/vhci_hcd.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2012-03-13 19:07:18 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-10 09:28:04 -0700
commitba46ce30f13a13bb24d05e21df2571ad724f1a1e (patch)
tree1bf3d9685389f6effee3db17307409abe9093e2d /drivers/staging/usbip/vhci_hcd.c
parentstaging/rtl8192e - fix typo in printk message (diff)
downloadlinux-dev-ba46ce30f13a13bb24d05e21df2571ad724f1a1e.tar.xz
linux-dev-ba46ce30f13a13bb24d05e21df2571ad724f1a1e.zip
staging: usbip: fix the usage of kthread_stop()
stub_shutdown_connection() and vhci_shutdown_connection() use task_is_dead() before kthread_stop(). This buys nothing and wrong. kthread_stop() is fine even if this thread is dead. However, if it is dead nothing protects this task_struct, we shouldn't touch this memory. Change the code to do the necessary get_task_struct/put_task_struct. This patch assumes that - xxx_shutdown_connection() is always called, so we can't leak the task_struct. - kthread_stop_put() can't be called twice on the same task. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Tobias Klauser <tklauser@distanz.ch> Cc: Matt Mooney <mfm@muteddisk.com>, Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/usbip/vhci_hcd.c')
-rw-r--r--drivers/staging/usbip/vhci_hcd.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
index dca9bf11f0c2..f708cbaee16b 100644
--- a/drivers/staging/usbip/vhci_hcd.c
+++ b/drivers/staging/usbip/vhci_hcd.c
@@ -821,10 +821,10 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
}
/* kill threads related to this sdev, if v.c. exists */
- if (vdev->ud.tcp_rx && !task_is_dead(vdev->ud.tcp_rx))
- kthread_stop(vdev->ud.tcp_rx);
- if (vdev->ud.tcp_tx && !task_is_dead(vdev->ud.tcp_tx))
- kthread_stop(vdev->ud.tcp_tx);
+ if (vdev->ud.tcp_rx)
+ kthread_stop_put(vdev->ud.tcp_rx);
+ if (vdev->ud.tcp_tx)
+ kthread_stop_put(vdev->ud.tcp_tx);
pr_info("stop threads\n");