From: Matthias Fuchs <matthias.fuchs@esd.eu>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>,
Maximilian Schneider <max@schneidersoft.net>
Subject: Re: [PATCH] net: can: esd_usb2: check index of array before accessing
Date: Wed, 3 Jul 2013 12:00:24 +0200 [thread overview]
Message-ID: <51D3F638.3080207@esd.eu> (raw)
In-Reply-To: <1372840409-13481-1-git-send-email-mkl@pengutronix.de>
Hi,
did anybody encounter an issue with invalid net codes comming from the
device?
Well, you may add my
Acked-by: Matthias Fuchs <matthias.fuchs@esd.eu>
Matthias
On 03.07.2013 10:33, Marc Kleine-Budde wrote:
> From: Maximilian Schneider <max@schneidersoft.net>
>
> The esd_usb2_read_bulk_callback() function is parsing the data that comes from
> the USB CAN adapter. One datum is used as an index to access the dev->nets[]
> array. This patch adds the missing bounds checking.
>
> Cc: Matthias Fuchs <matthias.fuchs@esd.eu>
> Signed-off-by: Maximilian Schneider <max@schneidersoft.net>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
> Hello,
>
> Maximilian, I've added a more detailed patch description and the error message
> printing. What do you think.
>
> Marc
>
> drivers/net/can/usb/esd_usb2.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/net/can/usb/esd_usb2.c b/drivers/net/can/usb/esd_usb2.c
> index 6aa7b32..ac6177d 100644
> --- a/drivers/net/can/usb/esd_usb2.c
> +++ b/drivers/net/can/usb/esd_usb2.c
> @@ -412,10 +412,20 @@ static void esd_usb2_read_bulk_callback(struct urb *urb)
>
> switch (msg->msg.hdr.cmd) {
> case CMD_CAN_RX:
> + if (msg->msg.rx.net >= dev->net_count) {
> + dev_err(dev->udev->dev.parent, "format error\n");
> + break;
> + }
> +
> esd_usb2_rx_can_msg(dev->nets[msg->msg.rx.net], msg);
> break;
>
> case CMD_CAN_TX:
> + if (msg->msg.txdone.net >= dev->net_count) {
> + dev_err(dev->udev->dev.parent, "format error\n");
> + break;
> + }
> +
> esd_usb2_tx_done_msg(dev->nets[msg->msg.txdone.net],
> msg);
> break;
>
next prev parent reply other threads:[~2013-07-03 10:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-03 8:33 [PATCH] net: can: esd_usb2: check index of array before accessing Marc Kleine-Budde
2013-07-03 10:00 ` Matthias Fuchs [this message]
2013-07-03 10:04 ` Marc Kleine-Budde
2013-07-03 11:51 ` Max S.
2013-07-03 11:51 ` Marc Kleine-Budde
[not found] ` <51D41E53.2030900@esd.eu>
2013-07-03 13:04 ` Marc Kleine-Budde
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=51D3F638.3080207@esd.eu \
--to=matthias.fuchs@esd.eu \
--cc=linux-can@vger.kernel.org \
--cc=max@schneidersoft.net \
--cc=mkl@pengutronix.de \
/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