Browse Source

can: kvaser_usb: check number of channels returned by HW

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>
Olivier Sobrie 11 years ago
parent
commit
862474f8b4
1 changed files with 2 additions and 0 deletions
  1. 2 0
      drivers/net/can/usb/kvaser_usb.c

+ 2 - 0
drivers/net/can/usb/kvaser_usb.c

@@ -473,6 +473,8 @@ static int kvaser_usb_get_card_info(struct kvaser_usb *dev)
 		return err;
 		return err;
 
 
 	dev->nchannels = msg.u.cardinfo.nchannels;
 	dev->nchannels = msg.u.cardinfo.nchannels;
+	if (dev->nchannels > MAX_NET_DEVICES)
+		return -EINVAL;
 
 
 	return 0;
 	return 0;
 }
 }