Commit e31c1880 authored by Oliver Neukum's avatar Oliver Neukum Committed by Greg Kroah-Hartman

USB: fix usb_serial_suspend(): buggy code

Am Montag 23 Juli 2007 schrieb Adrian Bunk:
> Commit ec22559e added the following 
> function to drivers/usb/serial/usb-serial.c:
> 
[..]
> 
> The Coverity checker spotted the inconsequent NULL checking for "serial".
> 
> Looking at the code it also doesn't seem to have been intended to always 
> return 0.

Coverity is right. The check for NULL is wrongly done and the error
return is lost.
Signed-off-by: default avatarOliver Neukum <oneukum@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 209b3cfd
...@@ -1077,16 +1077,17 @@ int usb_serial_suspend(struct usb_interface *intf, pm_message_t message) ...@@ -1077,16 +1077,17 @@ int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
struct usb_serial_port *port; struct usb_serial_port *port;
int i, r = 0; int i, r = 0;
if (serial) { if (!serial) /* device has been disconnected */
return 0;
for (i = 0; i < serial->num_ports; ++i) { for (i = 0; i < serial->num_ports; ++i) {
port = serial->port[i]; port = serial->port[i];
if (port) if (port)
kill_traffic(port); kill_traffic(port);
} }
}
if (serial->type->suspend) if (serial->type->suspend)
serial->type->suspend(serial, message); r = serial->type->suspend(serial, message);
return r; return r;
} }
......
Markdown is supported
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