]> git.baikalelectronics.ru Git - kernel.git/commit
can: gs_usb: fix use of uninitialized variable, detach device on reception of invalid...
authorMarc Kleine-Budde <mkl@pengutronix.de>
Fri, 10 Dec 2021 09:03:09 +0000 (10:03 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Wed, 5 Jan 2022 20:49:06 +0000 (21:49 +0100)
commitd5536667142d90bc874d7714104847e2e7f7d1b5
treedbc6baa628ad4b247b773d97eaeb61df09f8e62e
parent48f6cc618887973cd68b2f10ca9b3f886c5245e1
can: gs_usb: fix use of uninitialized variable, detach device on reception of invalid USB data

The received data contains the channel the received data is associated
with. If the channel number is bigger than the actual number of
channels assume broken or malicious USB device and shut it down.

This fixes the error found by clang:

| drivers/net/can/usb/gs_usb.c:386:6: error: variable 'dev' is used
|                                     uninitialized whenever 'if' condition is true
|         if (hf->channel >= GS_MAX_INTF)
|             ^~~~~~~~~~~~~~~~~~~~~~~~~~
| drivers/net/can/usb/gs_usb.c:474:10: note: uninitialized use occurs here
|                           hf, dev->gs_hf_size, gs_usb_receive_bulk_callback,
|                               ^~~

Link: https://lore.kernel.org/all/20211210091158.408326-1-mkl@pengutronix.de
Fixes: f619109f865f ("can: gs_usb: Added support for the GS_USB CAN devices")
Cc: stable@vger.kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/usb/gs_usb.c