ch_report_wireless() loads report->field[0]->hidinput->input before testing it, so the !input check never protects anything. ch_probe() sets HID_QUIRK_INPUT_PER_APP, and hidinput_connect() drops a hid_input that has no mapped usage, which makes hidinput_cleanup_hidinput() set field->hidinput back to NULL. A device whose Wireless Radio Controls application has only a constant input field therefore hits a NULL dereference on its first report from IRQ context. Reproduced with a raw-gadget device (04f2:1123) whose descriptor has such an application with report id 0x11: send the report "11 00" via hidraw. Log: [ 40.751093][ C1] Oops: general protection fault, probably for non-canonical address 0xdffffc0000000003: 0000 [#1] SMP KASAN NOPTI [ 40.752332][ C1] KASAN: null-ptr-deref in range [0x0000000000000018-0x000000000000001f] [ 40.753190][ C1] CPU: 1 UID: 0 PID: 25 Comm: kworker/1:0 Not tainted 7.4.0-rc5-g007722b8211f #1 PREEMPT(full) [ 40.754222][ C1] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 [ 40.755124][ C1] Workqueue: usb_hub_wq hub_event [ 40.755636][ C1] RIP: 0010:ch_raw_event+0x170/0x240 [ 40.756177][ C1] Code: 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 bf 00 00 00 48 b8 00 00 00 00 00 fc ff df 48 8b 5b 78 48 8d 7b 18 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 92 00 00 00 48 8b 6b 18 48 85 ed 74 61 e8 b8 f0 [ 40.758092][ C1] RSP: 0018:ffffc900001f8b08 EFLAGS: 00010016 [ 40.758695][ C1] RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000101 [ 40.759481][ C1] RDX: 0000000000000003 RSI: ffffffff8909b74c RDI: 0000000000000018 [ 40.760265][ C1] RBP: 0000000000000001 R08: ffffffff8909b73e R09: 0000000000000001 [ 40.761050][ C1] R10: ffff8880151c98e3 R11: 0000000000000001 R12: ffff8880151c8000 [ 40.761833][ C1] R13: ffff88804f645680 R14: 0000000000000002 R15: ffff8880151c98e0 [ 40.762616][ C1] FS: 0000000000000000(0000) GS:ffff8880e9481000(0000) knlGS:0000000000000000 [ 40.763503][ C1] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 40.764157][ C1] CR2: 00005636ecb1e5d8 CR3: 000000004ecbf000 CR4: 0000000000350ef0 [ 40.764945][ C1] Call Trace: [ 40.765273][ C1] [ 40.765559][ C1] __hid_input_report.constprop.0+0x31e/0x480 [ 40.766170][ C1] ? __pfx_ch_raw_event+0x10/0x10 [ 40.766678][ C1] ? ktime_get_mono_fast_ns+0x1c2/0x330 [ 40.767237][ C1] hid_irq_in+0x38c/0x8b0 [ 40.767675][ C1] __usb_hcd_giveback_urb+0x2e6/0x610 [ 40.768222][ C1] usb_hcd_giveback_urb+0x39b/0x460 [ 40.768746][ C1] dummy_timer+0x144b/0x35c0 [ 40.769218][ C1] ? find_held_lock+0x2b/0x80 [ 40.769700][ C1] ? find_held_lock+0x2b/0x80 [ 40.770176][ C1] ? __pfx_dummy_timer+0x10/0x10 [ 40.770679][ C1] ? _raw_spin_unlock_irqrestore+0x5a/0x70 [ 40.771267][ C1] __hrtimer_run_queues+0x17f/0xa00 [ 40.771791][ C1] ? __pfx_dummy_timer+0x10/0x10 [ 40.772285][ C1] hrtimer_run_softirq+0x1c9/0x360 [ 40.772734][ C1] handle_softirqs+0x20e/0x9e0 [ 40.773166][ C1] __irq_exit_rcu+0x184/0x240 [ 40.773583][ C1] irq_exit_rcu+0x9/0x30 [ 40.773967][ C1] sysvec_apic_timer_interrupt+0xa8/0xc0 [ 40.774463][ C1] [ 40.774722][ C1] [ 40.774987][ C1] asm_sysvec_apic_timer_interrupt+0x1a/0x20 [ 40.775512][ C1] RIP: 0010:finish_task_switch.isra.0+0x366/0x1100 [ 40.776090][ C1] Code: 0a 00 00 41 c7 87 20 0e 00 00 00 00 00 00 0f 1f 44 00 00 49 8d 7f 48 e8 28 61 4e 0a e8 33 1b 3e 00 fb 65 48 8b 1d 92 e4 0b 14 <48> 8d bb 18 17 00 00 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 [ 40.777757][ C1] RSP: 0018:ffffc900004cf420 EFLAGS: 00000202 [ 40.778291][ C1] RAX: 000000000003e761 RBX: ffff888040a98000 RCX: 0000000000000040 [ 40.778979][ C1] RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000000 [ 40.779662][ C1] RBP: ffffc900004cf470 R08: 0000000000000001 R09: 0000000000000001 [ 40.780351][ C1] R10: ffffffff924c939f R11: 0000000000000001 R12: ffff888047c55dc0 [ 40.781041][ C1] R13: 0000000000000000 R14: ffff888047c55dc0 R15: ffff88807ee3cc80 [ 40.781734][ C1] ? __switch_to+0x7a7/0x10d0 [ 40.782156][ C1] __schedule+0x13bb/0x75a0 [ 40.782561][ C1] ? try_to_wake_up+0x161/0x18f0 [ 40.783002][ C1] ? __pfx___schedule+0x10/0x10 [ 40.783436][ C1] ? lock_acquire+0x1bf/0x370 [ 40.783853][ C1] ? preempt_schedule_thunk+0x16/0x40 [ 40.784326][ C1] preempt_schedule+0x5d/0xd0 [ 40.784741][ C1] preempt_schedule_thunk+0x16/0x40 [ 40.785206][ C1] __mutex_unlock_slowpath+0x6bf/0x910 [ 40.785687][ C1] ? find_held_lock+0x2b/0x80 [ 40.786106][ C1] ? __pfx___mutex_unlock_slowpath+0x10/0x10 [ 40.786641][ C1] ? _raw_spin_unlock_irqrestore+0x5a/0x70 [ 40.787158][ C1] ? lockdep_hardirqs_on+0x7d/0x110 [ 40.787618][ C1] ? _raw_spin_unlock_irqrestore+0x41/0x70 [ 40.788136][ C1] __device_attach+0x26d/0x4e0 [ 40.788557][ C1] ? __pfx___device_attach+0x10/0x10 [ 40.789026][ C1] ? do_raw_spin_unlock+0x147/0x1f0 [ 40.789485][ C1] device_initial_probe+0xaa/0xe0 [ 40.789931][ C1] __bus_probe_device+0x60/0x150 [ 40.790370][ C1] device_add+0x1179/0x1950 [ 40.790771][ C1] ? __pfx_device_add+0x10/0x10 [ 40.791204][ C1] ? add_device_randomness+0xc9/0x110 [ 40.791681][ C1] usb_new_device+0xd30/0x1ac0 [ 40.792111][ C1] ? __pfx_usb_new_device+0x10/0x10 [ 40.792572][ C1] ? _raw_spin_unlock_irq+0x23/0x50 [ 40.793037][ C1] hub_event+0x2ed1/0x5000 [ 40.793438][ C1] ? __pfx_hub_event+0x10/0x10 [ 40.793869][ C1] ? process_one_work+0x90a/0x1dd0 [ 40.794322][ C1] ? _raw_spin_unlock_irq+0x23/0x50 [ 40.794781][ C1] process_one_work+0xabf/0x1dd0 [ 40.795224][ C1] ? __pfx_hcd_resume_work+0x10/0x10 [ 40.795692][ C1] ? __pfx_process_one_work+0x10/0x10 [ 40.796167][ C1] ? __pfx_hub_event+0x10/0x10 [ 40.796597][ C1] worker_thread+0x693/0xeb0 [ 40.797011][ C1] ? __pfx_worker_thread+0x10/0x10 [ 40.797466][ C1] kthread+0x390/0x4a0 [ 40.797831][ C1] ? __pfx_kthread+0x10/0x10 [ 40.798238][ C1] ret_from_fork+0xb0c/0xdb0 [ 40.798649][ C1] ? __pfx_ret_from_fork+0x10/0x10 [ 40.799102][ C1] ? __pfx_kthread+0x10/0x10 [ 40.799513][ C1] ? kthread_affine_node+0x180/0x230 [ 40.799981][ C1] ? __switch_to+0x7a7/0x10d0 [ 40.800394][ C1] ? __pfx_kthread+0x10/0x10 [ 40.800800][ C1] ret_from_fork_asm+0x1a/0x30 [ 40.801230][ C1] [ 40.801498][ C1] Modules linked in: [ 40.801845][ C1] ---[ end trace 0000000000000000 ]--- [ 40.802316][ C1] RIP: 0010:ch_raw_event+0x170/0x240 [ 40.802333][ C1] Code: 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 bf 00 00 00 48 b8 00 00 00 00 00 fc ff df 48 8b 5b 78 48 8d 7b 18 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 92 00 00 00 48 8b 6b 18 48 85 ed 74 61 e8 b8 f0 [ 40.802343][ C1] RSP: 0018:ffffc900001f8b08 EFLAGS: 00010016 [ 40.802351][ C1] RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000101 [ 40.802358][ C1] RDX: 0000000000000003 RSI: ffffffff8909b74c RDI: 0000000000000018 [ 40.802365][ C1] RBP: 0000000000000001 R08: ffffffff8909b73e R09: 0000000000000001 [ 40.802371][ C1] R10: ffff8880151c98e3 R11: 0000000000000001 R12: ffff8880151c8000 [ 40.802378][ C1] R13: ffff88804f645680 R14: 0000000000000002 R15: ffff8880151c98e0 [ 40.802386][ C1] FS: 0000000000000000(0000) GS:ffff8880e9481000(0000) knlGS:0000000000000000 [ 40.802396][ C1] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 40.802403][ C1] CR2: 00005636ecb1e5d8 CR3: 000000004ecbf000 CR4: 0000000000350ef0 [ 40.802411][ C1] Kernel panic - not syncing: Fatal exception in interrupt [ 40.811135][ C1] Kernel Offset: disabled [ 40.811512][ C1] Rebooting in 86400 seconds.. Report NULL hidinput instead of dereferencing it, and ratelimit the warning. Fixes: 859b510bb7fa5797 ("HID: chicony: Add Wireless Radio Control feature for Chicony devices") Cc: stable@vger.kernel.org Assisted-by: ZCode:GLM-5.4 Signed-off-by: Jaegyun Lee --- v1: https://lore.kernel.org/all/20261205032508.1267520-1-dreams200260@gmail.com/ drivers/hid/hid-chicony.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-chicony.c b/drivers/hid/hid-chicony.c index 5776ec2..236e795 100644 --- a/drivers/hid/hid-chicony.c +++ b/drivers/hid/hid-chicony.c @@ -26,14 +26,17 @@ static int ch_report_wireless(struct hid_report *report, u8 *data, int size) { struct hid_device *hdev = report->device; + struct hid_input *hidinput; struct input_dev *input; if (report->id != CH_WIRELESS_CTL_REPORT_ID || report->maxfield != 1) return 0; - input = report->field[0]->hidinput->input; + hidinput = report->field[0]->hidinput; + input = hidinput ? hidinput->input : NULL; if (!input) { - hid_warn(hdev, "can't find wireless radio control's input"); + hid_warn_ratelimited(hdev, + "can't find wireless radio control's input\n"); return 0; }