staging/usbip fixes
PATCH 3/7 staging: usbip: vhci: give back URBs from in-flight unlink requests
In reply to Max VozelerIf we never received a RET_UNLINK because the TCP connection broke the pending URBs still need to be unlinked and given back.
Previously processes would be stuck trying to kill the URB even after the device was detached.
--- drivers/staging/usbip/vhci.h | 3 +++ drivers/staging/usbip/vhci_hcd.c | 24 +++++++++++++++++++++++- drivers/staging/usbip/vhci_rx.c | 15 +++++++++------ 3 files changed, 35 insertions(+), 7 deletions(-)
drivers/staging/usbip/vhci.h +3 -0
@@ -119,6 +119,9 @@ void rh_port_disconnect(int rhport);void vhci_rx_loop (struct usbip_task *ut);void vhci_tx_loop (struct usbip_task *ut); +struct urb *pickup_urb_and_free_priv (struct vhci_device *vdev, +__u32 seqnum); +#define hardware (&the_controller->pdev.dev)static inline struct vhci_device *port_to_vdev (__u32 port)
drivers/staging/usbip/vhci_hcd.c +23 -1
@@ -808,7 +808,6 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)return 0 ; } -static void vhci_device_unlink_cleanup (struct vhci_device *vdev) {struct vhci_unlink *unlink, *tmp;
@@ -816,11 +815,34 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev)spin_lock (&vdev->priv_lock);list_for_each_entry_safe (unlink, tmp, &vdev->unlink_tx, list) { +usbip_uinfo ("unlink cleanup tx %lu\n" , unlink->unlink_seqnum);list_del (&unlink->list);kfree (unlink); }list_for_each_entry_safe (unlink, tmp, &vdev->unlink_rx, list) { +struct urb *urb; + +/* give back URB of unanswered unlink request */ +usbip_uinfo ("unlink cleanup rx %lu\n" , unlink->unlink_seqnum); + + urb =pickup_urb_and_free_priv (vdev, unlink->unlink_seqnum); +if (!urb) { +usbip_uinfo ("the urb (seqnum %lu) was already given back\n" , + unlink->unlink_seqnum); +list_del (&unlink->list); +kfree (unlink); +continue ; + } + + urb->status = -ENODEV ; + +spin_lock (&the_controller->lock); +usb_hcd_unlink_urb_from_ep (vhci_to_hcd (the_controller), urb); +spin_unlock (&the_controller->lock); + +usb_hcd_giveback_urb (vhci_to_hcd (the_controller), urb, urb->status); +list_del (&unlink->list);kfree (unlink); }
drivers/staging/usbip/vhci_rx.c +9 -6
@@ -23,16 +23,14 @@#include "vhci.h" -/* get URB from transmitted urb queue */ -static struct urb *pickup_urb_and_free_priv (struct vhci_device *vdev, +/* get URB from transmitted urb queue. caller must hold vdev->priv_lock */ +struct urb *pickup_urb_and_free_priv (struct vhci_device *vdev,__u32 seqnum) {struct vhci_priv *priv, *tmp;struct urb *urb =NULL ;int status; -spin_lock (&vdev->priv_lock); -list_for_each_entry_safe (priv, tmp, &vdev->priv_rx, list) {if (priv->seqnum == seqnum) { urb = priv->urb;
@@ -63,8 +61,6 @@ static struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev, } } -spin_unlock (&vdev->priv_lock); -return urb; }
@@ -74,9 +70,11 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,struct usbip_device *ud = &vdev->ud;struct urb *urb; +spin_lock (&vdev->priv_lock); urb =pickup_urb_and_free_priv (vdev, pdu->base.seqnum); +spin_unlock (&vdev->priv_lock);if (!urb) { usbip_uerr("cannot find a urb of seqnum %u\n",
@@ -161,7 +159,12 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,return ; } +spin_lock (&vdev->priv_lock); + urb =pickup_urb_and_free_priv (vdev, unlink->unlink_seqnum); + +spin_unlock (&vdev->priv_lock); +if (!urb) {/* * I get the result of a unlink request. But, it seems that I
Signature · 1 line
1.7.2.3
cover staging/usbip fixes
These are fixes for problems found testing usbip in a larger setup with up to 13 devices attached at the same time (we changed VHCI_NPORTS for the tests).
Review of the usb reference counting changes would be much appreciated.
The change handling EAGAIN from connection timeouts set with SO_RCVTIMEO is admittedly not pretty, but the best we can do without breaking the protocol.
Max Vozeler (7):
staging: usbip: stub: update refcounts for devices and interfaces
staging: usbip: vhci: update reference count for usb_device
staging: usbip: vhci: give back URBs from in-flight unlink requests
staging: usbip: vhci: refuse to enqueue for dead connections
staging: usbip: vhci: friendly log messages for connection errors
staging: usbip: vhci: handle EAGAIN from SO_RCVTIMEO
staging: usbip: vhci: use urb->dev->portnum to find port
drivers/staging/usbip/stub.h | 1 + drivers/staging/usbip/stub_dev.c | 18 ++++++++++--- drivers/staging/usbip/stub_rx.c | 4 +- drivers/staging/usbip/vhci.h | 6 ++-- drivers/staging/usbip/vhci_hcd.c | 54 ++++++++++++++++++++++++++++++++----- drivers/staging/usbip/vhci_rx.c | 50 +++++++++++++++++++++++++++++----- 6 files changed, 108 insertions(+), 25 deletions(-)
Signature · 1 line
1.7.2.3
PATCH 1/7 staging: usbip: stub: update refcounts for devices and interfaces
The stub driver expects to access the usb interface and usb device structures even if the device has been disconnected in the meantime.
This change gets a reference to them in the stub probe function using usb_get_intf()/usb_get_dev() and drops them in the disconnect function.
This fixes an oops observed with a Logic Controls Line display (0fa8:a030) which disconnects itself when it is reset:
[ 1348.562274] BUG: unable to handle kernel paging request at 5f7433e5 [ 1348.562327] IP: [<c0393b02>] usb_lock_device_for_reset+0x22/0xd0 [ 1348.562374] *pde = 00000000 [ 1348.562397] Oops: 0000 [#1] [ 1348.562418] last sysfs file: /sys/devices/pci0000:00/0000:00:10.2/usb4/4-1/bConfigurationValue [ 1348.562454] Modules linked in: usbip vhci_hcd usbip_common_mod fbcon tileblit font bitblit softcursor serio_raw uvesafb pcspkr via_rng snd_via82xx gameport snd_ac97_codec ac97_bus snd_pcm_oss snd_mixer_oss snd_pcm snd_page_alloc snd_mpu401_uart snd_rawmidi snd_seq_oss snd_seq_midi_event snd_seq snd_timer snd_seq_device snd usbhid hid via_rhine soundcore mii igel_flash aufs pata_via [ 1348.562649] [ 1348.562670] Pid: 2855, comm: usbip_eh Not tainted (2.6.32 #23.37-ud-r113) M300C [ 1348.562704] EIP: 0060:[<c0393b02>] EFLAGS: 00010216 CPU: 0 [ 1348.562734] EIP is at usb_lock_device_for_reset+0x22/0xd0 [ 1348.562762] EAX: 5f7433cd EBX: 5f7433cd ECX: de293a5c EDX: dd326a00 [ 1348.562793] ESI: 5f7433cd EDI: 000400f6 EBP: cf43ff48 ESP: cf43ff38 [ 1348.562824] DS: 007b ES: 007b FS: 0000 GS: 00e0 SS: 0068 [ 1348.562854] Process usbip_eh (pid: 2855, ti=cf43e000 task=d2c7f230 task.ti=cf43e000) [ 1348.562884] Stack: [ 1348.562900] d6ec9960 de2939cc 5f7433cd 5f743431 cf43ff70 df8fd32f de2939cc d2c7f230 [ 1348.562940] <0> cf43ff70 00000282 00000282 de2939cc d2c7f230 d2c7f230 cf43ffa8 df84416d [ 1348.562987] <0> cf43ff88 d2c7f230 de293a24 d2c7f230 00000000 d2c7f230 c014e760 cf43ff94 [ 1348.563042] Call Trace: [ 1348.563073] [<df8fd32f>] ? stub_device_reset+0x3f/0x110 [usbip] [ 1348.563114] [<df84416d>] ? event_handler_loop+0xcd/0xe8 [usbip_common_mod] [ 1348.563156] [<c014e760>] ? autoremove_wake_function+0x0/0x50 [ 1348.563193] [<df843d80>] ? usbip_thread+0x0/0x60 [usbip_common_mod] [ 1348.563230] [<df843dd1>] ? usbip_thread+0x51/0x60 [usbip_common_mod] [ 1348.563265] [<c014e374>] ? kthread+0x74/0x80 [ 1348.563294] [<c014e300>] ? kthread+0x0/0x80 [ 1348.563326] [<c0103c47>] ? kernel_thread_helper+0x7/0x10 [ 1348.563351] Code: 00 e8 73 4d 00 00 5d c3 90 55 89 e5 83 ec 10 89 5d f4 89 75 f8 89 7d fc 0f 1f 44 00 00 8b 3d c0 2e 67 c0 81 c7 fa 00 00 00 89 c3 <8b> 40 18 89 d6 85 c0 75 15 b8 ed ff ff ff 8b 5d f4 8b 75 f8 8b [ 1348.563528] EIP: [<c0393b02>] usb_lock_device_for_reset+0x22/0xd0 SS:ESP 0068:cf43ff38 [ 1348.563570] CR2: 000000005f7433e5 [ 1348.563593] ---[ end trace 9c3f1e3a2e5299d9 ]---
--- drivers/staging/usbip/stub.h | 1 + drivers/staging/usbip/stub_dev.c | 18 ++++++++++++++---- drivers/staging/usbip/stub_rx.c | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-)
drivers/staging/usbip/stub.h +1 -0
@@ -32,6 +32,7 @@struct stub_device {struct usb_interface *interface; +struct usb_device *udev;struct list_head list;struct usbip_device ud;
drivers/staging/usbip/stub_dev.c +14 -4
@@ -258,10 +258,11 @@ static void stub_shutdown_connection(struct usbip_device *ud)static void stub_device_reset (struct usbip_device *ud) { struct stub_device *sdev = container_of(ud, struct stub_device, ud); -struct usb_device *udev =interface_to_usbdev (sdev->interface); +struct usb_device *udev = sdev->udev;int ret;usbip_udbg ("device reset" ); + ret =usb_lock_device_for_reset (udev, sdev->interface);if (ret <0 ) {dev_err (&udev->dev,"lock for reset\n" );
@@ -309,7 +310,8 @@ static void stub_device_unusable(struct usbip_device *ud)* * Allocates and initializes a new stub_device struct. */ -static struct stub_device *stub_device_alloc (struct usb_interface *interface) +static struct stub_device *stub_device_alloc (struct usb_device *udev, +struct usb_interface *interface) {struct stub_device *sdev;int busnum =interface_to_busnum (interface);
@@ -324,7 +326,8 @@ static struct stub_device *stub_device_alloc(struct usb_interface *interface)return NULL ; } - sdev->interface = interface; + sdev->interface =usb_get_intf (interface); + sdev->udev =usb_get_dev (udev);/* * devid is defined with devnum when this driver is first allocated.
@@ -450,11 +453,12 @@ static int stub_probe(struct usb_interface *interface,return err; } +usb_get_intf (interface);return 0 ; }/* ok. this is my device. */ - sdev =stub_device_alloc (interface); + sdev =stub_device_alloc (udev, interface);if (!sdev)return -ENOMEM ;
@@ -476,6 +480,8 @@ static int stub_probe(struct usb_interface *interface,dev_err (&interface->dev,"create sysfs files for %s\n" , udev_busid);usb_set_intfdata (interface,NULL ); +usb_put_intf (interface); + busid_priv->interf_count =0 ; busid_priv->sdev =NULL ;
@@ -545,6 +551,7 @@ static void stub_disconnect(struct usb_interface *interface)if (busid_priv->interf_count >1 ) { busid_priv->interf_count--;shutdown_busid (busid_priv); +usb_put_intf (interface);return ; }
@@ -554,6 +561,9 @@ static void stub_disconnect(struct usb_interface *interface)/* 1. shutdown the current connection */ shutdown_busid (busid_priv); +usb_put_dev (sdev->udev); +usb_put_intf (interface); +/* 3. free sdev */ busid_priv->sdev =NULL ;stub_device_free (sdev);
drivers/staging/usbip/stub_rx.c +2 -2
@@ -364,7 +364,7 @@ static struct stub_priv *stub_priv_alloc(struct stub_device *sdev,static int get_pipe (struct stub_device *sdev,int epnum,int dir) { -struct usb_device *udev =interface_to_usbdev (sdev->interface); +struct usb_device *udev = sdev->udev;struct usb_host_endpoint *ep;struct usb_endpoint_descriptor *epd =NULL ;
@@ -484,7 +484,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,int ret;struct stub_priv *priv;struct usbip_device *ud = &sdev->ud; -struct usb_device *udev =interface_to_usbdev (sdev->interface); +struct usb_device *udev = sdev->udev;int pipe =get_pipe (sdev, pdu->base.ep, pdu->base.direction);
Signature · 1 line
1.7.2.3
PATCH 4/7 staging: usbip: vhci: refuse to enqueue for dead connections
In reply to Max VozelerThere can be requests to enqueue URBs while we are shutting down a connection.
--- drivers/staging/usbip/vhci_hcd.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-)
drivers/staging/usbip/vhci_hcd.c +13 -2
@@ -559,6 +559,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,struct device *dev = &urb->dev->dev;int ret =0 ;unsigned long flags; +struct vhci_device *vdev;usbip_dbg_vhci_hc ("enter, usb_hcd %p urb %p mem_flags %d\n" , hcd, urb, mem_flags);
@@ -574,6 +575,18 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,return urb->status; } + vdev =port_to_vdev (the_controller->pending_port); + +/* refuse enqueue for dead connection */ +spin_lock (&vdev->ud.lock); +if (vdev->ud.status ==VDEV_ST_NULL || vdev->ud.status ==VDEV_ST_ERROR ) { +usbip_uerr ("enqueue for inactive port %d\n" , vdev->rhport); +spin_unlock (&vdev->ud.lock); +spin_unlock_irqrestore (&the_controller->lock, flags); +return -ENODEV ; + } +spin_unlock (&vdev->ud.lock); + ret =usb_hcd_link_urb_to_ep (hcd, urb);if (ret) goto no_need_unlink;
@@ -592,8 +605,6 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,__u8 type =usb_pipetype (urb->pipe);struct usb_ctrlrequest *ctrlreq = (struct usb_ctrlrequest *) urb->setup_packet; -struct vhci_device *vdev = -port_to_vdev (the_controller->pending_port);if (type !=PIPE_CONTROL || !ctrlreq) {dev_err (dev,"invalid request to devnum 0\n" );
Signature · 1 line
1.7.2.3
PATCH 7/7 staging: usbip: vhci: use urb->dev->portnum to find port
In reply to Max VozelerThe access to pending_port was racy when two devices were being attached at the same time.
--- drivers/staging/usbip/vhci.h | 3 --- drivers/staging/usbip/vhci_hcd.c | 4 +--- 2 files changed, 1 insertions(+), 6 deletions(-)
drivers/staging/usbip/vhci.h +0 -3
@@ -100,9 +100,6 @@ struct vhci_hcd {* But, the index of this array begins from 0. */ struct vhci_device vdev[VHCI_NPORTS ]; - -/* vhci_device which has not been assiged its address yet */ -int pending_port; };
drivers/staging/usbip/vhci_hcd.c +1 -3
@@ -138,8 +138,6 @@ void rh_port_connect(int rhport, enum usb_device_speed speed)* the_controller->vdev[rhport].ud.status = VDEV_CONNECT; * spin_unlock(&the_controller->vdev[rhport].ud.lock); */ - the_controller->pending_port = rhport; -spin_unlock_irqrestore (&the_controller->lock, flags);usb_hcd_poll_rh_status (vhci_to_hcd (the_controller));
@@ -575,7 +573,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,return urb->status; } - vdev =port_to_vdev (the_controller->pending_port); + vdev =port_to_vdev (urb->dev->portnum-1 );/* refuse enqueue for dead connection */ spin_lock (&vdev->ud.lock);
Signature · 1 line
1.7.2.3
PATCH 6/7 staging: usbip: vhci: handle EAGAIN from SO_RCVTIMEO
In reply to Max VozelerIf there is a receive timeout without any active requests, we can tell the connection was idle and ignore the timeout.
If there are active requests for which we expect to receive a reply we close the connection.
This makes it possible to set an upper bound on the time a usbip device may be unresponsive.
This is a workaround for the lack of heart-beat messages in the USBIP protocol.
Extending the protocol would break compatibility with all previous stub versions, so this seems like the lesser evil.
--- drivers/staging/usbip/vhci_rx.c | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-)
drivers/staging/usbip/vhci_rx.c +20 -1
@@ -193,6 +193,19 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,return ; } +static int vhci_priv_tx_empty (struct vhci_device *vdev) +{ +int empty =0 ; + +spin_lock (&vdev->priv_lock); + + empty =list_empty (&vdev->priv_rx); + +spin_unlock (&vdev->priv_lock); + +return empty; +} +/* recv a pdu */ static void vhci_rx_pdu (struct usbip_device *ud) {
@@ -210,8 +223,14 @@ static void vhci_rx_pdu(struct usbip_device *ud)if (ret <0 ) {if (ret == -ECONNRESET )usbip_uinfo ("connection reset by peer\n" ); -else if (ret != -ERESTARTSYS ) +else if (ret == -EAGAIN ) { +/* ignore if connection was idle */ +if (vhci_priv_tx_empty (vdev)) +return ; +usbip_uinfo ("connection timed out with pending urbs\n" ); + }else if (ret != -ERESTARTSYS )usbip_uinfo ("xmit failed %d\n" , ret); +usbip_event_add (ud,VDEV_EVENT_ERROR_TCP );return ; }
Signature · 1 line
1.7.2.3
PATCH 5/7 staging: usbip: vhci: friendly log messages for connection errors
In reply to Max VozelerAlso changes the event on connection close to beVDEV_EVENT_DOWN - no functional change.
--- drivers/staging/usbip/vhci_rx.c | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-)
drivers/staging/usbip/vhci_rx.c +14 -2
@@ -205,11 +205,23 @@ static void vhci_rx_pdu(struct usbip_device *ud)memset (&pdu,0 ,sizeof (pdu)); -/* 1. receive a pdu header */ ret =usbip_xmit (0 , ud->tcp_socket, (char *) &pdu,sizeof (pdu),0 ); +if (ret <0 ) { +if (ret == -ECONNRESET ) +usbip_uinfo ("connection reset by peer\n" ); +else if (ret != -ERESTARTSYS ) +usbip_uinfo ("xmit failed %d\n" , ret); +usbip_event_add (ud,VDEV_EVENT_ERROR_TCP ); +return ; + } +if (ret ==0 ) { +usbip_uinfo ("connection closed" ); +usbip_event_add (ud,VDEV_EVENT_DOWN ); +return ; + }if (ret !=sizeof (pdu)) { -usbip_uerr ("receiving pdu failed! size is %d, should be %d\n" , +usbip_uerr ("received pdu size is %d, should be %d\n" , ret, (unsigned int )sizeof (pdu));usbip_event_add (ud,VDEV_EVENT_ERROR_TCP );return ;
Signature · 1 line
1.7.2.3
PATCH 2/7 staging: usbip: vhci: update reference count for usb_device
In reply to Max VozelerThis fixes an oops observed when reading status during removal of a device:
[ 1706.648285] general protection fault: 0000 [#1] SMP [ 1706.648294] last sysfs file: /sys/devices/platform/vhci_hcd/status [ 1706.648297] CPU 1 [ 1706.648300] Modules linked in: binfmt_misc microcode fuse loop vhci_hcd(N) usbip(N) usbcore usbip_common_mod(N) rtc_core rtc_lib joydev dm_mirror dm_region_hash dm_log linear dm_snapshot xennet dm_mod ext3 mbcache jbd processor thermal_sys hwmon xenblk cdrom [ 1706.648324] Supported: Yes [ 1706.648327] Pid: 10422, comm: usbip Tainted: G N 2.6.32.12-0.7-xen #1 [ 1706.648330] RIP: e030:[<ffffffff801b10d5>] [<ffffffff801b10d5>] strnlen+0x5/0x40 [ 1706.648340] RSP: e02b:ffff8800a994dd30 EFLAGS: 00010286 [ 1706.648343] RAX: ffffffff80481ec1 RBX: 0000000000000000 RCX: 0000000000000002 [ 1706.648347] RDX: 00200d1d4f1c001c RSI: ffffffffffffffff RDI: 00200d1d4f1c001c [ 1706.648350] RBP: ffff880129a1c0aa R08: ffffffffa01901c4 R09: 0000000000000006 [ 1706.648353] R10: 0000000000000000 R11: 0000000000000000 R12: ffff8800a9a1c0ab [ 1706.648357] R13: 00200d1d4f1c001c R14: 00000000ffffffff R15: ffff880129a1c0aa [ 1706.648363] FS: 00007f2f2e9ca700(0000) GS:ffff880001018000(0000) knlGS:0000000000000000 [ 1706.648367] CS: e033 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1706.648370] CR2: 000000000071b048 CR3: 00000000b4b68000 CR4: 0000000000002660 [ 1706.648374] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 1706.648378] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [ 1706.648381] Process usbip (pid: 10422, threadinfo ffff8800a994c000, task ffff88007b170200) [ 1706.648385] Stack: [ 1706.648387] ffffffff801b28c9 0000000000000002 ffffffffa01901c4 ffff8800a9a1c0ab [ 1706.648391] <0> ffffffffa01901c6 ffff8800a994de08 ffffffff801b339b 0000000000000004 [ 1706.648397] <0> 0000000affffffff ffffffffffffffff 00000000000067c0 0000000000000000 [ 1706.648404] Call Trace: [ 1706.648413] [<ffffffff801b28c9>] string+0x39/0xe0 [ 1706.648419] [<ffffffff801b339b>] vsnprintf+0x1eb/0x620 [ 1706.648423] [<ffffffff801b3813>] sprintf+0x43/0x50 [ 1706.648429] [<ffffffffa018d719>] show_status+0x1b9/0x220 [vhci_hcd] [ 1706.648438] [<ffffffff8024a2b7>] dev_attr_show+0x27/0x60 [ 1706.648445] [<ffffffff80144821>] sysfs_read_file+0x101/0x1d0 [ 1706.648451] [<ffffffff800da4a7>] vfs_read+0xc7/0x130 [ 1706.648457] [<ffffffff800da613>] sys_read+0x53/0xa0 [ 1706.648462] [<ffffffff80007458>] system_call_fastpath+0x16/0x1b [ 1706.648468] [<00007f2f2de40f30>] 0x7f2f2de40f30 [ 1706.648470] Code: 66 0f 1f 44 00 00 48 83 c2 01 80 3a 00 75 f7 48 89 d0 48 29 f8 f3 c3 66 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 48 85 f6 74 29 <80> 3f 00 74 24 48 8d 56 ff 48 89 f8 eb 0e 0f 1f 44 00 00 48 83 [ 1706.648507] RIP [<ffffffff801b10d5>] strnlen+0x5/0x40 [ 1706.648511] RSP <ffff8800a994dd30> [ 1706.649575] ---[ end trace b4eb72bf2e149593 ]---
--- drivers/staging/usbip/vhci_hcd.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-)
drivers/staging/usbip/vhci_hcd.c +10 -3
@@ -607,7 +607,9 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,dev_info (dev,"SetAddress Request (%d) to port %d\n" , ctrlreq->wValue, vdev->rhport); - vdev->udev = urb->dev; +if (vdev->udev) +usb_put_dev (vdev->udev); + vdev->udev =usb_get_dev (urb->dev);spin_lock (&vdev->ud.lock); vdev->ud.status =VDEV_ST_USED ;
@@ -627,8 +629,9 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,"Get_Descriptor to device 0 " "(get max pipe size)\n"); -/* FIXME: reference count? (usb_get_dev()) */ - vdev->udev = urb->dev; +if (vdev->udev) +usb_put_dev (vdev->udev); + vdev->udev =usb_get_dev (urb->dev); goto out;default :
@@ -887,6 +890,10 @@ static void vhci_device_reset(struct usbip_device *ud) vdev->speed =0 ; vdev->devid =0 ; +if (vdev->udev) +usb_put_dev (vdev->udev); + vdev->udev =NULL ; + ud->tcp_socket =NULL ; ud->status =VDEV_ST_NULL ;
Signature · 1 line
1.7.2.3