>From 9eeb93b5c3a78bcf2090415da96170a6de53b927 Mon Sep 17 00:00:00 2001 From: Oliver Neukum <oliver@xxxxxxxxxx> Date: Sat, 30 Jan 2010 21:57:30 +0100 Subject: [PATCH] usb:cdc-wdm:Fix deadlock between write and resume The device must be resumed before the lock is taken Signed-off-by: Oliver Neukum <oliver@xxxxxxxxxx> --- This should go into rc7. Stable is not affected. drivers/usb/class/cdc-wdm.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index 5ef40c8..1c0d353 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c @@ -321,26 +321,26 @@ static ssize_t wdm_write goto outnl; } + r = usb_autopm_get_interface(desc->intf); + if (r < 0) { + kfree(buf); + goto outnl; + } + /* concurrent writes and disconnect */ r = mutex_lock_interruptible(&desc->lock); rv = -ERESTARTSYS; if (r) { kfree(buf); - goto outnl; + goto outnp; } if (test_bit(WDM_DISCONNECTING, &desc->flags)) { kfree(buf); rv = -ENODEV; - goto outnp; + goto out; } - r = usb_autopm_get_interface(desc->intf); - if (r < 0) { - kfree(buf); - goto outnp; - } - if (!file->f_flags && O_NONBLOCK) r = wait_event_interruptible(desc->wait, !test_bit(WDM_IN_USE, &desc->flags)); @@ -383,9 +383,9 @@ static ssize_t wdm_write req->wIndex); } out: - usb_autopm_put_interface(desc->intf); -outnp: mutex_unlock(&desc->lock); +outnp: + usb_autopm_put_interface(desc->intf); outnl: return rv < 0 ? rv : count; } -- 1.6.4.2 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html