Re: [PATCH] usb: ljca: fix NULL pointer dereference on events for callback-less clients

From: Greg Kroah-Hartman

Date: Fri Nov 20 2026 - 11:06:36 EST


On Fri, Nov 20, 2026 at 11:01:43PM +0800, YuanZhe Liu wrote:
> ljca_handle_event() dispatches an incoming event message to the first
> client whose type matches the message type and calls that client's event
> callback without checking that a callback is registered. Only the GPIO
> client calls ljca_register_event_cb(); the I2C and SPI clients never do,
> so their event_cb stays NULL for as long as the adapter is bound, while
> they are present in adap->client_list.
>
> A device that sends a message without LJCA_ACK_FLAG and with the type of
> such a client therefore makes the driver call a NULL function pointer
> from the URB completion handler:

What device does that? How?

>
> BUG: kernel NULL pointer dereference, address: 0000000000000000
> #PF: supervisor instruction fetch in kernel mode
> RIP: 0010:0x0
> Call Trace:
> ljca_handle_event drivers/usb/misc/usb-ljca.c:217 [inline]
> ljca_recv+0x651/0x850 drivers/usb/misc/usb-ljca.c:295
> __usb_hcd_giveback_urb+0x238/0x550 drivers/usb/core/hcd.c:1657
>
> Check event_cb under client->event_cb_lock and skip the call when no
> callback is registered. The same lock is taken by
> ljca_register_event_cb() and ljca_unregister_event_cb(), so the check
> cannot be invalidated before the call.

How was this tested, shouldn't the driver be fixed up not to do that
instead of this workaround?

thanks,

greg k-h