Skip to content

Commit

Permalink
USB: sierra: add more checks on shutdown
Browse files Browse the repository at this point in the history
This should help with any potential NULL pointer usages as reported by a
few users.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Greg Kroah-Hartman committed Apr 27, 2007
1 parent 931384f commit f094e4f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/usb/serial/sierra.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand All @@ -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]) {
Expand All @@ -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));
}
}
Expand Down

0 comments on commit f094e4f

Please sign in to comment.