aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Vozeler <max@hinterhof.net>2011-04-18 15:44:10 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-04-25 20:09:51 -0400
commitd1b2e95ab016a0c5b01748986f6ce42e9d11cab2 (patch)
treec79cd57a4acf50e485eeebc552ac045cd48c98af
parent9f908a9eaa94f07265811c59b740a4608d3dfc96 (diff)
staging: usbip: vhci: fix oops on subsequent attach
vhci_rx/vhci_tx threads are created once but stopped each time the vdev is shut down. On subsequent attach wake_up_process() oopses trying to access the stopped threads. This patch does as before the kthread conversion which is to create the threads each time a device is attached and stop the threads when the device is shut down. Signed-off-by: Max Vozeler <max@hinterhof.net> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Takahiro Hirofuchi <hirofuchi@users.sourceforge.net> Cc: Arjan Mels <arjan.mels@gmx.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/usbip/vhci_hcd.c9
-rw-r--r--drivers/staging/usbip/vhci_sysfs.c7
2 files changed, 8 insertions, 8 deletions
diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
index 0f02a4b12ae4..14caae279f7e 100644
--- a/drivers/staging/usbip/vhci_hcd.c
+++ b/drivers/staging/usbip/vhci_hcd.c
@@ -876,8 +876,10 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
876 } 876 }
877 877
878 /* kill threads related to this sdev, if v.c. exists */ 878 /* kill threads related to this sdev, if v.c. exists */
879 kthread_stop(vdev->ud.tcp_rx); 879 if (vdev->ud.tcp_rx)
880 kthread_stop(vdev->ud.tcp_tx); 880 kthread_stop(vdev->ud.tcp_rx);
881 if (vdev->ud.tcp_tx)
882 kthread_stop(vdev->ud.tcp_tx);
881 883
882 usbip_uinfo("stop threads\n"); 884 usbip_uinfo("stop threads\n");
883 885
@@ -949,9 +951,6 @@ static void vhci_device_init(struct vhci_device *vdev)
949{ 951{
950 memset(vdev, 0, sizeof(*vdev)); 952 memset(vdev, 0, sizeof(*vdev));
951 953
952 vdev->ud.tcp_rx = kthread_create(vhci_rx_loop, &vdev->ud, "vhci_rx");
953 vdev->ud.tcp_tx = kthread_create(vhci_tx_loop, &vdev->ud, "vhci_tx");
954
955 vdev->ud.side = USBIP_VHCI; 954 vdev->ud.side = USBIP_VHCI;
956 vdev->ud.status = VDEV_ST_NULL; 955 vdev->ud.status = VDEV_ST_NULL;
957 /* vdev->ud.lock = SPIN_LOCK_UNLOCKED; */ 956 /* vdev->ud.lock = SPIN_LOCK_UNLOCKED; */
diff --git a/drivers/staging/usbip/vhci_sysfs.c b/drivers/staging/usbip/vhci_sysfs.c
index 3f2459f30415..e2dadbd5ef1e 100644
--- a/drivers/staging/usbip/vhci_sysfs.c
+++ b/drivers/staging/usbip/vhci_sysfs.c
@@ -21,6 +21,7 @@
21#include "vhci.h" 21#include "vhci.h"
22 22
23#include <linux/in.h> 23#include <linux/in.h>
24#include <linux/kthread.h>
24 25
25/* TODO: refine locking ?*/ 26/* TODO: refine locking ?*/
26 27
@@ -220,13 +221,13 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
220 vdev->ud.tcp_socket = socket; 221 vdev->ud.tcp_socket = socket;
221 vdev->ud.status = VDEV_ST_NOTASSIGNED; 222 vdev->ud.status = VDEV_ST_NOTASSIGNED;
222 223
223 wake_up_process(vdev->ud.tcp_rx);
224 wake_up_process(vdev->ud.tcp_tx);
225
226 spin_unlock(&vdev->ud.lock); 224 spin_unlock(&vdev->ud.lock);
227 spin_unlock(&the_controller->lock); 225 spin_unlock(&the_controller->lock);
228 /* end the lock */ 226 /* end the lock */
229 227
228 vdev->ud.tcp_rx = kthread_run(vhci_rx_loop, &vdev->ud, "vhci_rx");
229 vdev->ud.tcp_tx = kthread_run(vhci_tx_loop, &vdev->ud, "vhci_tx");
230
230 rh_port_connect(rhport, speed); 231 rh_port_connect(rhport, speed);
231 232
232 return count; 233 return count;