public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* keyspan_pda.c use of keyspan_pda_get_modem_info
@ 2008-06-26 14:52 Benny Halevy
  2008-06-26 15:23 ` Alan Cox
  0 siblings, 1 reply; 8+ messages in thread
From: Benny Halevy @ 2008-06-26 14:52 UTC (permalink / raw)
  To: Greg KH; +Cc: lkml

with gcc 4.3.0 i see these warnings:

drivers/usb/serial/keyspan_pda.c: In function 'keyspan_pda_tiocmget':
drivers/usb/serial/keyspan_pda.c:444: warning: 'status' may be used uninitialized in this function
drivers/usb/serial/keyspan_pda.c: In function 'keyspan_pda_tiocmset':
drivers/usb/serial/keyspan_pda.c:465: warning: 'status' may be used uninitialized in this function

In these two call sites the callers bail out if
keyspan_pda_get_modem_info return value is < 0
e.g.
static int keyspan_pda_tiocmget(struct usb_serial_port *port, struct file *file)
{
...
	unsigned char status;
...
	rc = keyspan_pda_get_modem_info(serial, &status);
	if (rc < 0)
		return rc;
	value =
		((status & (1<<7)) ? TIOCM_DTR : 0) |
...
	return value;

However, keyspan_pda_get_modem_info sets status only for rc > 0
so it may indeed be used uninitialized in case keyspan_pda_get_modem_info
returns 0.

static int keyspan_pda_get_modem_info(struct usb_serial *serial,
				      unsigned char *value)
{
	int rc;
	unsigned char data;
	rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
			     3, /* get pins */
			     USB_TYPE_VENDOR|USB_RECIP_INTERFACE|USB_DIR_IN,
			     0, 0, &data, 1, 2000);
	if (rc > 0)
		*value = data;
	return rc;
}

In the usb_control_msg/usb_internal_control_msg/usb_start_wait_urb path,
if usb_submit_urb

That said, I'm not sure if that can happen at all but regardless,
it seems like a good idea to handle this case.

Benny

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-06-27 20:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-26 14:52 keyspan_pda.c use of keyspan_pda_get_modem_info Benny Halevy
2008-06-26 15:23 ` Alan Cox
2008-06-27  4:17   ` Greg KH
2008-06-27  7:18     ` Benny Halevy
2008-06-27  7:58       ` [PATCH] usb: fix uninitialized variables in keyspan_pda Benny Halevy
2008-06-27  8:58         ` Alan Cox
2008-06-27  9:22           ` Benny Halevy
2008-06-27 20:25             ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox