Commit efa73f13 authored by Tobias Klauser's avatar Tobias Klauser Committed by Greg Kroah-Hartman

Staging: usbip: vhci-hcd: Do not kill already dead RX/TX kthread

commit 8547d4cc upstream.

When unbinding a device on the host which was still attached on the
client, I got a NULL pointer dereference on the client. This turned out
to be due to kthread_stop() being called on an already dead kthread.

Here is how I was able to reproduce the problem:

 server:# usbip bind -b 1-2
                                client:# usbip attach -h server -b 1-2
 server:# usbip unbind -b 1-2

This patch fixes the problem by checking the kthread before attempting
to kill it, as it is done on the opposite side in
stub_shutdown_connection().
Signed-off-by: default avatarTobias Klauser <tklauser@distanz.ch>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 97edbc90
...@@ -846,9 +846,9 @@ static void vhci_shutdown_connection(struct usbip_device *ud) ...@@ -846,9 +846,9 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
} }
/* kill threads related to this sdev, if v.c. exists */ /* kill threads related to this sdev, if v.c. exists */
if (vdev->ud.tcp_rx) if (vdev->ud.tcp_rx && !task_is_dead(vdev->ud.tcp_rx))
kthread_stop(vdev->ud.tcp_rx); kthread_stop(vdev->ud.tcp_rx);
if (vdev->ud.tcp_tx) if (vdev->ud.tcp_tx && !task_is_dead(vdev->ud.tcp_tx))
kthread_stop(vdev->ud.tcp_tx); kthread_stop(vdev->ud.tcp_tx);
pr_info("stop threads\n"); pr_info("stop threads\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment