* usb_serial_suspend(): buggy(?) code
@ 2007-07-23 1:51 Adrian Bunk
2007-07-23 6:58 ` Oliver Neukum
0 siblings, 1 reply; 2+ messages in thread
From: Adrian Bunk @ 2007-07-23 1:51 UTC (permalink / raw)
To: Oliver Neukum, Greg Kroah-Hartman; +Cc: linux-usb-devel, linux-kernel
Commit ec22559e0b7a05283a3413bda5d177e42c950e23 added the following
function to drivers/usb/serial/usb-serial.c:
<-- snip -->
...
int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
{
struct usb_serial *serial = usb_get_intfdata(intf);
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->type->suspend)
serial->type->suspend(serial, message);
return r;
}
...
<-- snip -->
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.
cu
Adrian
--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: usb_serial_suspend(): buggy(?) code
2007-07-23 1:51 usb_serial_suspend(): buggy(?) code Adrian Bunk
@ 2007-07-23 6:58 ` Oliver Neukum
0 siblings, 0 replies; 2+ messages in thread
From: Oliver Neukum @ 2007-07-23 6:58 UTC (permalink / raw)
To: Adrian Bunk; +Cc: Greg Kroah-Hartman, linux-usb-devel, linux-kernel
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.
Regards
Oliver
Signed-off-by: Oliver Neukum <oneukum@suse.de>
--
--- a/drivers/usb/serial/usb-serial.c 2007-07-23 08:47:35.000000000 +0200
+++ b/drivers/usb/serial/usb-serial.c 2007-07-23 08:49:20.000000000 +0200
@@ -1077,16 +1077,17 @@ int usb_serial_suspend(struct usb_interf
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;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-07-23 6:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-23 1:51 usb_serial_suspend(): buggy(?) code Adrian Bunk
2007-07-23 6:58 ` Oliver Neukum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox