linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] can: kvaser_usb: check number of channels returned by HW
@ 2014-02-11 10:01 Olivier Sobrie
  2014-02-11 10:09 ` Marc Kleine-Budde
  0 siblings, 1 reply; 5+ messages in thread
From: Olivier Sobrie @ 2014-02-11 10:01 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: linux-can, Olivier Sobrie

It is needed to check the number of channels returned by the HW
because it cannot be greater than MAX_NET_DEVICES otherwise
it will crash.

Signed-off-by: Olivier Sobrie <olivier@sobrie.be>
---
 drivers/net/can/usb/kvaser_usb.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c
index 4b2d5ed..cc3df8a 100644
--- a/drivers/net/can/usb/kvaser_usb.c
+++ b/drivers/net/can/usb/kvaser_usb.c
@@ -474,6 +474,8 @@ static int kvaser_usb_get_card_info(struct kvaser_usb *dev)
 		return err;
 
 	dev->nchannels = msg.u.cardinfo.nchannels;
+	if (dev->nchannels > MAX_NET_DEVICES)
+		return -EINVAL;
 
 	return 0;
 }
-- 
1.7.9.5


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

* Re: [PATCH] can: kvaser_usb: check number of channels returned by HW
  2014-02-11 10:01 [PATCH] can: kvaser_usb: check number of channels returned by HW Olivier Sobrie
@ 2014-02-11 10:09 ` Marc Kleine-Budde
  2014-02-11 12:33   ` Olivier Sobrie
  0 siblings, 1 reply; 5+ messages in thread
From: Marc Kleine-Budde @ 2014-02-11 10:09 UTC (permalink / raw)
  To: Olivier Sobrie; +Cc: linux-can

[-- Attachment #1: Type: text/plain, Size: 628 bytes --]

On 02/11/2014 11:01 AM, Olivier Sobrie wrote:
> It is needed to check the number of channels returned by the HW
> because it cannot be greater than MAX_NET_DEVICES otherwise
> it will crash.
>
> Signed-off-by: Olivier Sobrie <olivier@sobrie.be>

Does this bug occur on any kvaser USB hardware?
However, I think, I'll add stable on Cc

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 242 bytes --]

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

* Re: [PATCH] can: kvaser_usb: check number of channels returned by HW
  2014-02-11 10:09 ` Marc Kleine-Budde
@ 2014-02-11 12:33   ` Olivier Sobrie
  2014-02-11 12:36     ` Marc Kleine-Budde
  0 siblings, 1 reply; 5+ messages in thread
From: Olivier Sobrie @ 2014-02-11 12:33 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: linux-can

Hello Marc,

On Tue, Feb 11, 2014 at 11:09:57AM +0100, Marc Kleine-Budde wrote:
> On 02/11/2014 11:01 AM, Olivier Sobrie wrote:
> > It is needed to check the number of channels returned by the HW
> > because it cannot be greater than MAX_NET_DEVICES otherwise
> > it will crash.
> >
> > Signed-off-by: Olivier Sobrie <olivier@sobrie.be>
> 
> Does this bug occur on any kvaser USB hardware?

I never see it with the devices I have and nobody reported me a problem
regarding this. I found this bug by chance while I was looking to add
support for Kvaser device from usbcanII family.

> However, I think, I'll add stable on Cc

Good idea :-)
Thank you,

-- 
Olivier

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

* Re: [PATCH] can: kvaser_usb: check number of channels returned by HW
  2014-02-11 12:33   ` Olivier Sobrie
@ 2014-02-11 12:36     ` Marc Kleine-Budde
  0 siblings, 0 replies; 5+ messages in thread
From: Marc Kleine-Budde @ 2014-02-11 12:36 UTC (permalink / raw)
  To: Olivier Sobrie; +Cc: linux-can

[-- Attachment #1: Type: text/plain, Size: 1009 bytes --]

On 02/11/2014 01:33 PM, Olivier Sobrie wrote:
> Hello Marc,
> 
> On Tue, Feb 11, 2014 at 11:09:57AM +0100, Marc Kleine-Budde wrote:
>> On 02/11/2014 11:01 AM, Olivier Sobrie wrote:
>>> It is needed to check the number of channels returned by the HW
>>> because it cannot be greater than MAX_NET_DEVICES otherwise
>>> it will crash.
>>>
>>> Signed-off-by: Olivier Sobrie <olivier@sobrie.be>
>>
>> Does this bug occur on any kvaser USB hardware?
> 
> I never see it with the devices I have and nobody reported me a problem
> regarding this. I found this bug by chance while I was looking to add
> support for Kvaser device from usbcanII family.

Tnx, I'll include the patch in my next pull request to David.

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 242 bytes --]

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

* [PATCH] can: kvaser_usb: check number of channels returned by HW
  2014-02-12 10:35 pull-request: can 2014-02-12 Marc Kleine-Budde
@ 2014-02-12 10:35 ` Marc Kleine-Budde
  0 siblings, 0 replies; 5+ messages in thread
From: Marc Kleine-Budde @ 2014-02-12 10:35 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-can, kernel, Olivier Sobrie, linux-stable,
	Marc Kleine-Budde

From: Olivier Sobrie <olivier@sobrie.be>

It is needed to check the number of channels returned by the HW because it
cannot be greater than MAX_NET_DEVICES otherwise it will crash.

Signed-off-by: Olivier Sobrie <olivier@sobrie.be>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/kvaser_usb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c
index 6c859bb..e77d110 100644
--- a/drivers/net/can/usb/kvaser_usb.c
+++ b/drivers/net/can/usb/kvaser_usb.c
@@ -473,6 +473,8 @@ static int kvaser_usb_get_card_info(struct kvaser_usb *dev)
 		return err;
 
 	dev->nchannels = msg.u.cardinfo.nchannels;
+	if (dev->nchannels > MAX_NET_DEVICES)
+		return -EINVAL;
 
 	return 0;
 }
-- 
1.8.5.3


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

end of thread, other threads:[~2014-02-12 10:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-11 10:01 [PATCH] can: kvaser_usb: check number of channels returned by HW Olivier Sobrie
2014-02-11 10:09 ` Marc Kleine-Budde
2014-02-11 12:33   ` Olivier Sobrie
2014-02-11 12:36     ` Marc Kleine-Budde
  -- strict thread matches above, loose matches on Subject: below --
2014-02-12 10:35 pull-request: can 2014-02-12 Marc Kleine-Budde
2014-02-12 10:35 ` [PATCH] can: kvaser_usb: check number of channels returned by HW Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).