]> 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:02 +0000 (10:01 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Sun, 16 Nov 2025 16:04:13 +0000 (17:04 +0100)
commit6fe9f3279f7d2518439a7962c5870c6e9ecbadcf
tree93e77bcf35d6f1a3bfdf6060009a1ac8b804a4f1
parent516a0cd1c03fa266bb67dd87940a209fd4e53ce7
can: gs_usb: gs_usb_receive_bulk_callback(): check actual_length before accessing header

The driver expects to receive a struct gs_host_frame in
gs_usb_receive_bulk_callback().

Use struct_group to describe the header of the struct gs_host_frame and
check that we have at least received the header before accessing any
members of it.

To resubmit the URB, do not dereference the pointer chain
"dev->parent->hf_size_rx" but use "parent->hf_size_rx" instead. Since
"urb->context" contains "parent", it is always defined, while "dev" is not
defined if the URB it too short.

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-2-a29b42eacada@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/usb/gs_usb.c