From: walter harms <wharms@bfs.de>
To: kernel-janitors@vger.kernel.org
Subject: Re: [patch 2/2 v2] USB: keyspan: add a sanity test on "len"
Date: Fri, 05 Apr 2013 07:09:04 +0000 [thread overview]
Message-ID: <515E7890.2070905@bfs.de> (raw)
In-Reply-To: <20130405054320.GB26528@longonot.mountain>
Am 05.04.2013 07:43, schrieb Dan Carpenter:
> "len" comes from the USB transfer and it's probably correct. The thing
> is that we already have similar checks like:
>
> if (data[i] >= serial->num_ports) {
>
> So adding a sanity test here matches the rest of the code and is a good
> idea.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2: No change. Rebased.
>
> diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
> index 3d303f0..eb30d7b 100644
> --- a/drivers/usb/serial/keyspan.c
> +++ b/drivers/usb/serial/keyspan.c
> @@ -727,14 +727,15 @@ static void usa49wg_indat_callback(struct urb *urb)
> if ((data[i] & 0x80) = 0) {
> /* no error on any byte */
> i++;
> - for (x = 1; x < len ; ++x)
> + for (x = 1; x < len && i < urb->actual_length; ++x)
> tty_insert_flip_char(&port->port,
> data[i++], 0);
maybe is is a bit late ...
mixing i,x here is prone to error, the casual reader will be confused.
i suggest the following variation.
for (x = 1; x < len && i < urb->actual_length; ++x)
if (i < urb->actual_length)
tty_insert_flip_char(&port->port,ata[i++], 0);
> } else {
> /*
> * some bytes had errors, every byte has status
> */
> - for (x = 0; x + 1 < len; x += 2) {
> + for (x = 0; x + 1 < len &&
> + i + 1 < urb->actual_length; x += 2) {
> int stat = data[i], flag = 0;
>
> if (stat & RXERROR_OVERRUN)
same as above.
re,
wh
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
prev parent reply other threads:[~2013-04-05 7:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-05 5:43 [patch 2/2 v2] USB: keyspan: add a sanity test on "len" Dan Carpenter
2013-04-05 7:09 ` walter harms [this message]
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=515E7890.2070905@bfs.de \
--to=wharms@bfs.de \
--cc=kernel-janitors@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