]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
can: esd_usb: add endpoint type validation
authorZiyi Guo <n7l8m4@u.northwestern.edu>
Fri, 13 Feb 2026 20:39:27 +0000 (20:39 +0000)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Mon, 2 Mar 2026 10:03:32 +0000 (11:03 +0100)
commit968b098220e393a10488b6a5dddb302b2eaedf66
treee718b8cb039e514377f51448d0ff18ea1a1a3a6b
parentab3f894de216f4a62adc3b57e9191888cbf26885
can: esd_usb: add endpoint type validation

esd_usb_probe() constructs bulk pipes for two endpoints without
verifying their transfer types:

  - usb_rcvbulkpipe(dev->udev, 1) for RX (version reply, async RX data)
  - usb_sndbulkpipe(dev->udev, 2) for TX (version query, CAN frames)

A malformed USB device can present these endpoints with transfer types
that differ from what the driver assumes, triggering the WARNING in
usb_submit_urb().

Use usb_find_common_endpoints() to discover and validate the first
bulk IN and bulk OUT endpoints at probe time, before any allocation.
Found pipes are saved to struct esd_usb and code uses them directly
instead of making pipes in place.

Similar to
- commit 136bed0bfd3b ("can: mcba_usb: properly check endpoint type")
  which established the usb_find_common_endpoints() + stored pipes
  pattern for CAN USB drivers.

Fixes: 96d8e90382dc ("can: Add driver for esd CAN-USB/2 device")
Suggested-by: Vincent Mailhol <mailhol@kernel.org>
Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>
Reviewed-by: Vincent Mailhol <mailhol@kernel.org>
Link: https://patch.msgid.link/20260213203927.599163-1-n7l8m4@u.northwestern.edu
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/usb/esd_usb.c