]> Gentwo Git Trees - linux/.git/commit
can: gs_usb: gs_usb_receive_bulk_callback(): check actual_length before accessing...
authorMarc Kleine-Budde <mkl@pengutronix.de>
Sat, 8 Nov 2025 09:01:03 +0000 (10:01 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Mon, 17 Nov 2025 16:21:16 +0000 (17:21 +0100)
commit395d988f93861101ec89d0dd9e3b876ae9392a5b
treeb3ccb4905061ec211aac62a11073f71eee4129bd
parent6fe9f3279f7d2518439a7962c5870c6e9ecbadcf
can: gs_usb: gs_usb_receive_bulk_callback(): check actual_length before accessing data

The URB received in gs_usb_receive_bulk_callback() contains a struct
gs_host_frame. The length of the data after the header depends on the
gs_host_frame hf::flags and the active device features (e.g. time
stamping).

Introduce a new function gs_usb_get_minimum_length() and check that we have
at least received the required amount of data before accessing it. Only
copy the data to that skb that has actually been received.

Fixes: d08e973a77d1 ("can: gs_usb: Added support for the GS_USB CAN devices")
Link: https://patch.msgid.link/20251114-gs_usb-fix-usb-callbacks-v1-3-a29b42eacada@pengutronix.de
[mkl: rename gs_usb_get_minimum_length() -> +gs_usb_get_minimum_rx_length()]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/usb/gs_usb.c