On Thu, 11 Apr 2019, Andrej Shadura wrote: > >>> So I still am not really happy about this being wired up into generic HID > >>> although it's really a USB driver, but we've discussed that already, and I > >>> don't see any option that'd work substantially better in this case, > >>> especially from the UX point of view. Oh well. Applied to for-5.2/u2fzero, > >>> thanks! > >>> > >> > >> Hi wish I were CC-ed on these threads. > > > > Gah, for some reason I was convinced you were. > > > >> My CI script now fails because hid-u2fzero.ko needs devm_hwrng_register > >> and the Kconfig doesn't force pulling the right dependency. > > >> Also, you probably want to add in .probe() a check for the actual > >> transport driver (`hid_is_using_ll_driver(hdev, &usb_hid_driver)`) or > >> you can not use the usbhid functions without crashing the kernel. > > Thanks, that’s very useful. > > > Benjamin, I love your CI :) > > > > Andrej, could you please send fixups on top of the applied patch? > > Sure, will do. I didn't receive any followup; the Kconfig dependency has already been fixed by Mao Wenan, and I've just queued the patch below on top of that as well. From: Jiri Kosina <jkosina@xxxxxxx> Subject: [PATCH] HID: u2fzero: fail probe if not using USB transport u2fzero driver is USB-only. Therefore we have to give up in ->probe() callback in case we're called with non-USB transport driver bound, otherwise the kernel will crash trying to use USBHID API on a non-USB transport. Fixes: 42337b9d4d958("HID: add driver for U2F Zero built-in LED and RNG") Reported-by: Benjamin Tissoires <benjamin.tissoires@xxxxxxxxxx> Signed-off-by: Jiri Kosina <jkosina@xxxxxxx> --- drivers/hid/hid-u2fzero.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/hid/hid-u2fzero.c b/drivers/hid/hid-u2fzero.c index d11a5cb56a0d..95e0807878c7 100644 --- a/drivers/hid/hid-u2fzero.c +++ b/drivers/hid/hid-u2fzero.c @@ -286,6 +286,9 @@ static int u2fzero_probe(struct hid_device *hdev, unsigned int minor; int ret; + if (!hid_is_using_ll_driver(hdev, &usb_hid_driver)) + return -EINVAL; + dev = devm_kzalloc(&hdev->dev, sizeof(*dev), GFP_KERNEL); if (dev == NULL) return -ENOMEM; -- Jiri Kosina SUSE Labs