aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2012-05-09 07:53:22 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-05-11 18:19:22 -0400
commit6b0b79d38806481c1c8fffa7c5842f3c83679a42 (patch)
treea245e513829756b11694ced5a7ba1fb5dee38b67
parent616b6937e348ef2b4c6ea5fef2cd3c441145efb0 (diff)
USB: cdc-wdm: cannot use dev_printk when device is gone
We cannot dereference a removed USB interface for dev_printk. Use pr_debug instead where necessary. Flush errors are expected if device is unplugged and are therefore best ingored at this point. Move the kill_urbs() call in wdm_release with dev_dbg() for the non disconnect, as we know it has already been called if WDM_DISCONNECTING is set. This does not actually fix anything, but keeps the code more consistent. Cc: Oliver Neukum <oliver@neukum.org> Cc: stable <stable@vger.kernel.org> Signed-off-by: Bjørn Mork <bjorn@mork.no> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/class/cdc-wdm.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 765227575d3b..90bc916d7cbd 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -533,7 +533,9 @@ static int wdm_flush(struct file *file, fl_owner_t id)
533 struct wdm_device *desc = file->private_data; 533 struct wdm_device *desc = file->private_data;
534 534
535 wait_event(desc->wait, !test_bit(WDM_IN_USE, &desc->flags)); 535 wait_event(desc->wait, !test_bit(WDM_IN_USE, &desc->flags));
536 if (desc->werr < 0) 536
537 /* cannot dereference desc->intf if WDM_DISCONNECTING */
538 if (desc->werr < 0 && !test_bit(WDM_DISCONNECTING, &desc->flags))
537 dev_err(&desc->intf->dev, "Error in flush path: %d\n", 539 dev_err(&desc->intf->dev, "Error in flush path: %d\n",
538 desc->werr); 540 desc->werr);
539 541
@@ -625,12 +627,13 @@ static int wdm_release(struct inode *inode, struct file *file)
625 mutex_unlock(&desc->wlock); 627 mutex_unlock(&desc->wlock);
626 628
627 if (!desc->count) { 629 if (!desc->count) {
628 dev_dbg(&desc->intf->dev, "wdm_release: cleanup");
629 kill_urbs(desc);
630 if (!test_bit(WDM_DISCONNECTING, &desc->flags)) { 630 if (!test_bit(WDM_DISCONNECTING, &desc->flags)) {
631 dev_dbg(&desc->intf->dev, "wdm_release: cleanup");
632 kill_urbs(desc);
631 desc->manage_power(desc->intf, 0); 633 desc->manage_power(desc->intf, 0);
632 } else { 634 } else {
633 dev_dbg(&desc->intf->dev, "%s: device gone - cleaning up\n", __func__); 635 /* must avoid dev_printk here as desc->intf is invalid */
636 pr_debug(KBUILD_MODNAME " %s: device gone - cleaning up\n", __func__);
634 cleanup(desc); 637 cleanup(desc);
635 } 638 }
636 } 639 }