Gitweb: http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=e31c18804f584dd838a752f6628e8c15bd7a3372 Commit: e31c18804f584dd838a752f6628e8c15bd7a3372 Parent: 209b3cfd538e7d56d228cf6daf0b27e2cc26c6c2 Author: Oliver Neukum <[EMAIL PROTECTED]> AuthorDate: Mon Jul 23 08:58:39 2007 +0200 Committer: Greg Kroah-Hartman <[EMAIL PROTECTED]> CommitDate: Mon Jul 30 13:27:45 2007 -0700
USB: fix usb_serial_suspend(): buggy code Am Montag 23 Juli 2007 schrieb Adrian Bunk: > Commit ec22559e0b7a05283a3413bda5d177e42c950e23 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 <[EMAIL PROTECTED]> Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]> --- drivers/usb/serial/usb-serial.c | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index a366565..5e1cf78 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -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; } - To unsubscribe from this list: send the line "unsubscribe git-commits-head" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html