Skip to content

Commit

Permalink
USB: fix usb_serial_suspend(): buggy code
Browse files Browse the repository at this point in the history
Am Montag 23 Juli 2007 schrieb Adrian Bunk:
> Commit ec22559 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: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Oliver Neukum authored and Greg Kroah-Hartman committed Jul 30, 2007
1 parent 209b3cf commit e31c188
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions drivers/usb/serial/usb-serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1077,16 +1077,17 @@ int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
struct usb_serial_port *port;
int i, r = 0;

if (serial) {
for (i = 0; i < serial->num_ports; ++i) {
port = serial->port[i];
if (port)
kill_traffic(port);
}
if (!serial) /* device has been disconnected */
return 0;

for (i = 0; i < serial->num_ports; ++i) {
port = serial->port[i];
if (port)
kill_traffic(port);
}

if (serial->type->suspend)
serial->type->suspend(serial, message);
r = serial->type->suspend(serial, message);

return r;
}
Expand Down

0 comments on commit e31c188

Please sign in to comment.