Commit f094e4f3 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

USB: sierra: add more checks on shutdown



This should help with any potential NULL pointer usages as reported by a
few users.

Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 931384fb
......@@ -577,7 +577,12 @@ static void sierra_shutdown(struct usb_serial *serial)
/* Stop reading/writing urbs */
for (i = 0; i < serial->num_ports; ++i) {
port = serial->port[i];
if (!port)
continue;
portdata = usb_get_serial_port_data(port);
if (!portdata)
continue;
for (j = 0; j < N_IN_URB; j++)
usb_unlink_urb(portdata->in_urbs[j]);
for (j = 0; j < N_OUT_URB; j++)
......@@ -587,7 +592,11 @@ static void sierra_shutdown(struct usb_serial *serial)
/* Now free them */
for (i = 0; i < serial->num_ports; ++i) {
port = serial->port[i];
if (!port)
continue;
portdata = usb_get_serial_port_data(port);
if (!portdata)
continue;
for (j = 0; j < N_IN_URB; j++) {
if (portdata->in_urbs[j]) {
......@@ -606,6 +615,8 @@ static void sierra_shutdown(struct usb_serial *serial)
/* Now free per port private data */
for (i = 0; i < serial->num_ports; i++) {
port = serial->port[i];
if (!port)
continue;
kfree(usb_get_serial_port_data(port));
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment