From: Benny Halevy <bhalevy@panasas.com>
To: Greg KH <greg@kroah.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: keyspan_pda.c use of keyspan_pda_get_modem_info
Date: Thu, 26 Jun 2008 17:52:35 +0300 [thread overview]
Message-ID: <4863AD33.3070005@panasas.com> (raw)
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
next reply other threads:[~2008-06-26 14:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-26 14:52 Benny Halevy [this message]
2008-06-26 15:23 ` keyspan_pda.c use of keyspan_pda_get_modem_info 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4863AD33.3070005@panasas.com \
--to=bhalevy@panasas.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox