Re: [PATCH v2] can: esd_usb: add endpoint type validation
From: Vincent Mailhol
Date: Sun Feb 22 2026 - 08:05:55 EST
On 13/02/2026 at 21:39, Ziyi Guo wrote:
> 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@xxxxxxxxxx>
> Signed-off-by: Ziyi Guo <n7l8m4@xxxxxxxxxxxxxxxxxx>
Thanks for this v2.
Reviewed-by: Vincent Mailhol <mailhol@xxxxxxxxxx>
Yours sincerely,
Vincent Mailhol