From 7d54ba0e37130edda335e7f373f193014ede2a12 Mon Sep 17 00:00:00 2001 From: Kevin Baradon Date: Mon, 22 Apr 2013 16:09:45 -0300 Subject: [PATCH] [media] media/rc/imon.c: do not try to register 2nd intf if 1st intf failed This bug could be triggered if 1st interface configuration fails: Apr 8 18:20:30 homeserver kernel: usb 5-1: new low-speed USB device number 2 using ohci_hcd Apr 8 18:20:30 homeserver kernel: input: iMON Panel, Knob and Mouse(15c2:0036) as /devices/pci0000:00/0000:00:13.0/usb5/5-1/5-1:1.0/input/input2 Apr 8 18:20:30 homeserver kernel: Registered IR keymap rc-imon-pad Apr 8 18:20:30 homeserver kernel: input: iMON Remote (15c2:0036) as /devices/pci0000:00/0000:00:13.0/usb5/5-1/5-1:1.0/rc/rc0/input3 Apr 8 18:20:30 homeserver kernel: rc0: iMON Remote (15c2:0036) as /devices/pci0000:00/0000:00:13.0/usb5/5-1/5-1:1.0/rc/rc0 Apr 8 18:20:30 homeserver kernel: imon:send_packet: packet tx failed (-32) Apr 8 18:20:30 homeserver kernel: imon 5-1:1.0: remote input dev register failed Apr 8 18:20:30 homeserver kernel: imon 5-1:1.0: imon_init_intf0: rc device setup failed Apr 8 18:20:30 homeserver kernel: imon 5-1:1.0: unable to initialize intf0, err 0 Apr 8 18:20:30 homeserver kernel: imon:imon_probe: failed to initialize context! Apr 8 18:20:30 homeserver kernel: imon 5-1:1.0: unable to register, err -19 Apr 8 18:20:30 homeserver kernel: BUG: unable to handle kernel NULL pointer dereference at 00000014 Apr 8 18:20:30 homeserver kernel: IP: [] mutex_lock+0xc/0x30 Apr 8 18:20:30 homeserver kernel: *pde = 00000000 Apr 8 18:20:30 homeserver kernel: Oops: 0002 [#1] PREEMPT SMP Apr 8 18:20:30 homeserver kernel: Modules linked in: Apr 8 18:20:30 homeserver kernel: Pid: 367, comm: khubd Not tainted 3.8.3-htpc-00002-g79b1403 #23 Unknow Unknow/RS780-SB700 Apr 8 18:20:30 homeserver kernel: EIP: 0060:[] EFLAGS: 00010296 CPU: 1 Apr 8 18:20:30 homeserver kernel: EIP is at mutex_lock+0xc/0x30 Apr 8 18:20:30 homeserver kernel: EAX: 00000014 EBX: 00000014 ECX: 00000000 EDX: f590e480 Apr 8 18:20:30 homeserver kernel: ESI: f5deac00 EDI: f590e480 EBP: f5f3ee00 ESP: f6577c28 Apr 8 18:20:30 homeserver kernel: DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 Apr 8 18:20:30 homeserver kernel: CR0: 8005003b CR2: 00000014 CR3: 0081b000 CR4: 000007d0 Apr 8 18:20:30 homeserver kernel: DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000 Apr 8 18:20:30 homeserver kernel: DR6: ffff0ff0 DR7: 00000400 Apr 8 18:20:30 homeserver kernel: Process khubd (pid: 367, ti=f6576000 task=f649ea00 task.ti=f6576000) Apr 8 18:20:30 homeserver kernel: Stack: Apr 8 18:20:30 homeserver kernel: 00000000 f5deac00 c0448de4 f59714c0 f5deac64 c03b8ad2 f6577c90 00000004 Apr 8 18:20:30 homeserver kernel: f649ea00 c0205142 f6779820 a1ff7f08 f5deac00 00000001 f5f3ee1c 00000014 Apr 8 18:20:30 homeserver kernel: 00000004 00000202 15c20036 c07a03e8 fffee0ca f6795c00 f5f3ee1c f5deac00 Apr 8 18:20:30 homeserver kernel: Call Trace: Apr 8 18:20:30 homeserver kernel: [] ? imon_probe+0x494/0xde0 Apr 8 18:20:30 homeserver kernel: [] ? rpm_resume+0xb2/0x4f0 Apr 8 18:20:30 homeserver kernel: [] ? sysfs_addrm_finish+0x12/0x90 Apr 8 18:20:30 homeserver kernel: [] ? usb_probe_interface+0x169/0x240 Apr 8 18:20:30 homeserver kernel: [] ? __driver_attach+0x80/0x80 Apr 8 18:20:30 homeserver kernel: [] ? __driver_attach+0x80/0x80 Apr 8 18:20:30 homeserver kernel: [] ? driver_probe_device+0x54/0x1e0 Apr 8 18:20:30 homeserver kernel: [] ? usb_device_match+0x4e/0x80 Apr 8 18:20:30 homeserver kernel: [] ? bus_for_each_drv+0x34/0x70 Apr 8 18:20:30 homeserver kernel: [] ? device_attach+0x7b/0x90 Apr 8 18:20:30 homeserver kernel: [] ? __driver_attach+0x80/0x80 Apr 8 18:20:30 homeserver kernel: [] ? bus_probe_device+0x5f/0x80 Apr 8 18:20:30 homeserver kernel: [] ? device_add+0x567/0x610 Apr 8 18:20:30 homeserver kernel: [] ? usb_create_ep_devs+0x7c/0xd0 Apr 8 18:20:30 homeserver kernel: [] ? create_intf_ep_devs+0x47/0x70 Apr 8 18:20:30 homeserver kernel: [] ? usb_set_configuration+0x454/0x750 Apr 8 18:20:30 homeserver kernel: [] ? __driver_attach+0x80/0x80 Apr 8 18:20:30 homeserver kernel: [] ? generic_probe+0x2a/0x80 Apr 8 18:20:30 homeserver kernel: [] ? __driver_attach+0x80/0x80 Apr 8 18:20:30 homeserver kernel: [] ? sysfs_create_link+0xf/0x20 Apr 8 18:20:30 homeserver kernel: [] ? usb_probe_device+0x1b/0x40 Apr 8 18:20:30 homeserver kernel: [] ? driver_probe_device+0x54/0x1e0 Apr 8 18:20:30 homeserver kernel: [] ? bus_for_each_drv+0x34/0x70 Apr 8 18:20:30 homeserver kernel: [] ? device_attach+0x7b/0x90 Apr 8 18:20:30 homeserver kernel: [] ? __driver_attach+0x80/0x80 Apr 8 18:20:30 homeserver kernel: [] ? bus_probe_device+0x5f/0x80 Apr 8 18:20:30 homeserver kernel: [] ? device_add+0x567/0x610 Apr 8 18:20:30 homeserver kernel: [] ? usb_new_device+0x12f/0x1e0 Apr 8 18:20:30 homeserver kernel: [] ? hub_thread+0x458/0x1230 Apr 8 18:20:30 homeserver kernel: [] ? dequeue_task_fair+0x9f/0xc0 Apr 8 18:20:30 homeserver kernel: [] ? release_task+0x1d2/0x330 Apr 8 18:20:30 homeserver kernel: [] ? abort_exclusive_wait+0x90/0x90 Apr 8 18:20:30 homeserver kernel: [] ? usb_remote_wakeup+0x40/0x40 Apr 8 18:20:30 homeserver kernel: [] ? kthread+0x92/0xa0 Apr 8 18:20:30 homeserver kernel: [] ? ret_from_kernel_thread+0x1b/0x28 Apr 8 18:20:30 homeserver kernel: [] ? kthread_freezable_should_stop+0x50/0x50 Apr 8 18:20:30 homeserver kernel: Code: 89 04 24 89 f0 e8 05 ff ff ff 8b 5c 24 24 8b 74 24 28 8b 7c 24 2c 8b 6c 24 30 83 c4 34 c3 00 83 ec 08 89 1c 24 89 74 24 04 89 c3 ff 08 79 05 e8 ca 03 00 00 64 a1 70 d6 80 c0 8b 74 24 04 89 Apr 8 18:20:30 homeserver kernel: EIP: [] mutex_lock+0xc/0x30 SS:ESP 0068:f6577c28 Apr 8 18:20:30 homeserver kernel: CR2: 0000000000000014 Apr 8 18:20:30 homeserver kernel: ---[ end trace df134132c967205c ]--- Signed-off-by: Kevin Baradon Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/imon.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c index 624fd33d7086..3af7bb6c9f30 100644 --- a/drivers/media/rc/imon.c +++ b/drivers/media/rc/imon.c @@ -2324,7 +2324,14 @@ static int imon_probe(struct usb_interface *interface, } } else { - /* this is the secondary interface on the device */ + /* this is the secondary interface on the device */ + + /* fail early if first intf failed to register */ + if (!first_if_ctx) { + ret = -ENODEV; + goto fail; + } + ictx = imon_init_intf1(interface, first_if_ctx); if (!ictx) { pr_err("failed to attach to context!\n"); -- 2.30.2