Skip to content

Commit 9697f5e

Browse files
oneukumgregkh
authored andcommitted
USB: wdm: handle IO errors in wdm_wwan_port_start
In case submitting the URB fails we must undo what we've done so far. Fixes: cac6fb0 ("usb: class: cdc-wdm: WWAN framework integration") Cc: stable <stable@kernel.org> Signed-off-by: Oliver Neukum <oneukum@suse.com> Link: https://lore.kernel.org/r/20250401084749.175246-2-oneukum@suse.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e00b39a commit 9697f5e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/usb/class/cdc-wdm.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,7 @@ static struct usb_class_driver wdm_class = {
829829
static int wdm_wwan_port_start(struct wwan_port *port)
830830
{
831831
struct wdm_device *desc = wwan_port_get_drvdata(port);
832+
int rv;
832833

833834
/* The interface is both exposed via the WWAN framework and as a
834835
* legacy usbmisc chardev. If chardev is already open, just fail
@@ -848,7 +849,15 @@ static int wdm_wwan_port_start(struct wwan_port *port)
848849
wwan_port_txon(port);
849850

850851
/* Start getting events */
851-
return usb_submit_urb(desc->validity, GFP_KERNEL);
852+
rv = usb_submit_urb(desc->validity, GFP_KERNEL);
853+
if (rv < 0) {
854+
wwan_port_txoff(port);
855+
desc->manage_power(desc->intf, 0);
856+
/* this must be last lest we race with chardev open */
857+
clear_bit(WDM_WWAN_IN_USE, &desc->flags);
858+
}
859+
860+
return rv;
852861
}
853862

854863
static void wdm_wwan_port_stop(struct wwan_port *port)

0 commit comments

Comments
 (0)