]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.0.1/staging-usbip-vhci-hcd-do-not-kill-already-dead-rx-tx-kthread.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.0.1 / staging-usbip-vhci-hcd-do-not-kill-already-dead-rx-tx-kthread.patch
CommitLineData
e2cab6c9
GKH
1From 8547d4cc2b616e4f1dafebe2c673fc986422b506 Mon Sep 17 00:00:00 2001
2From: Tobias Klauser <tklauser@distanz.ch>
3Date: Fri, 24 Jun 2011 15:48:47 +0200
4Subject: Staging: usbip: vhci-hcd: Do not kill already dead RX/TX kthread
5
6From: Tobias Klauser <tklauser@distanz.ch>
7
8commit 8547d4cc2b616e4f1dafebe2c673fc986422b506 upstream.
9
10When unbinding a device on the host which was still attached on the
11client, I got a NULL pointer dereference on the client. This turned out
12to be due to kthread_stop() being called on an already dead kthread.
13
14Here is how I was able to reproduce the problem:
15
16 server:# usbip bind -b 1-2
17 client:# usbip attach -h server -b 1-2
18 server:# usbip unbind -b 1-2
19
20This patch fixes the problem by checking the kthread before attempting
21to kill it, as it is done on the opposite side in
22stub_shutdown_connection().
23
24Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
25Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
26
27---
28 drivers/staging/usbip/vhci_hcd.c | 4 ++--
29 1 file changed, 2 insertions(+), 2 deletions(-)
30
31--- a/drivers/staging/usbip/vhci_hcd.c
32+++ b/drivers/staging/usbip/vhci_hcd.c
33@@ -846,9 +846,9 @@ static void vhci_shutdown_connection(str
34 }
35
36 /* kill threads related to this sdev, if v.c. exists */
37- if (vdev->ud.tcp_rx)
38+ if (vdev->ud.tcp_rx && !task_is_dead(vdev->ud.tcp_rx))
39 kthread_stop(vdev->ud.tcp_rx);
40- if (vdev->ud.tcp_tx)
41+ if (vdev->ud.tcp_tx && !task_is_dead(vdev->ud.tcp_tx))
42 kthread_stop(vdev->ud.tcp_tx);
43
44 pr_info("stop threads\n");