]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.14/media-au0828-cannot-kfree-dev-before-usb-disconnect.patch
autosel patches for 4.14
[thirdparty/kernel/stable-queue.git] / queue-4.14 / media-au0828-cannot-kfree-dev-before-usb-disconnect.patch
1 From d4aeff2a2d413098f6c8d12d203070d7a2623ff6 Mon Sep 17 00:00:00 2001
2 From: Brad Love <brad@nextdimension.cc>
3 Date: Thu, 6 Sep 2018 17:07:48 -0400
4 Subject: media: au0828: cannot kfree dev before usb disconnect
5
6 [ Upstream commit 4add7104919f9e94e0db03e234caeadbfcc02ea9 ]
7
8 If au0828_analog_register fails, the dev is kfree'd and then flow
9 jumps to done, which can call au0828_usb_disconnect. Since all USB
10 error codes are negative, au0828_usb_disconnect will be called. The
11 problem is au0828_usb_disconnect uses dev, if dev is NULL then there
12 is immediate oops encountered.
13
14 [ 7.454307] au0828: au0828_usb_probe() au0282_dev_register failed to register on V4L2
15 [ 7.454323] BUG: unable to handle kernel NULL pointer dereference at 0000000000000050
16 [ 7.454421] PGD 0 P4D 0
17 [ 7.454457] Oops: 0002 [#1] SMP PTI
18 [ 7.454500] CPU: 1 PID: 262 Comm: systemd-udevd Tainted: P O 4.18.3 #1
19 [ 7.454584] Hardware name: Google Panther/Panther, BIOS MattDevo 04/27/2015
20 [ 7.454670] RIP: 0010:_raw_spin_lock_irqsave+0x2c/0x50
21 [ 7.454725] Code: 44 00 00 55 48 89 e5 41 54 53 48 89 fb 9c 58 0f 1f 44 00 00 49 89 c4 fa 66 0f 1f 44 00 00 e8 db 23 1b ff 31 c0 ba 01 00 00 00 <f0> 0f b1 13 85 c0 75 08 4c 89 e0 5b 41 5c 5d c3 89 c6 48 89 df e8
22 [ 7.455004] RSP: 0018:ffff9130f53ef988 EFLAGS: 00010046
23 [ 7.455063] RAX: 0000000000000000 RBX: 0000000000000050 RCX: 0000000000000000
24 [ 7.455139] RDX: 0000000000000001 RSI: 0000000000000003 RDI: 0000000000000050
25 [ 7.455216] RBP: ffff9130f53ef998 R08: 0000000000000018 R09: 0000000000000090
26 [ 7.455292] R10: ffffed4cc53cb000 R11: ffffed4cc53cb108 R12: 0000000000000082
27 [ 7.455369] R13: ffff9130cf2c6188 R14: 0000000000000000 R15: 0000000000000018
28 [ 7.455447] FS: 00007f2ff8514cc0(0000) GS:ffff9130fcb00000(0000) knlGS:0000000000000000
29 [ 7.455535] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
30 [ 7.455597] CR2: 0000000000000050 CR3: 00000001753f0002 CR4: 00000000000606a0
31 [ 7.455675] Call Trace:
32 [ 7.455713] __wake_up_common_lock+0x65/0xc0
33 [ 7.455764] __wake_up+0x13/0x20
34 [ 7.455808] ir_lirc_unregister+0x57/0xe0 [rc_core]
35 [ 7.455865] rc_unregister_device+0xa0/0xc0 [rc_core]
36 [ 7.455935] au0828_rc_unregister+0x25/0x40 [au0828]
37 [ 7.455999] au0828_usb_disconnect+0x33/0x80 [au0828]
38 [ 7.456064] au0828_usb_probe.cold.16+0x8d/0x2aa [au0828]
39 [ 7.456130] usb_probe_interface+0xf1/0x300
40 [ 7.456184] driver_probe_device+0x2e3/0x460
41 [ 7.456235] __driver_attach+0xe4/0x110
42 [ 7.456282] ? driver_probe_device+0x460/0x460
43 [ 7.456335] bus_for_each_dev+0x74/0xb0
44 [ 7.456385] ? kmem_cache_alloc_trace+0x15d/0x1d0
45 [ 7.456441] driver_attach+0x1e/0x20
46 [ 7.456485] bus_add_driver+0x159/0x230
47 [ 7.456532] driver_register+0x70/0xc0
48 [ 7.456578] usb_register_driver+0x7f/0x140
49 [ 7.456626] ? 0xffffffffc0474000
50 [ 7.456674] au0828_init+0xbc/0x1000 [au0828]
51 [ 7.456725] do_one_initcall+0x4a/0x1c9
52 [ 7.456771] ? _cond_resched+0x19/0x30
53 [ 7.456817] ? kmem_cache_alloc_trace+0x15d/0x1d0
54 [ 7.456873] do_init_module+0x60/0x210
55 [ 7.456918] load_module+0x221b/0x2710
56 [ 7.456966] ? vfs_read+0xf5/0x120
57 [ 7.457010] __do_sys_finit_module+0xbd/0x120
58 [ 7.457061] ? __do_sys_finit_module+0xbd/0x120
59 [ 7.457115] __x64_sys_finit_module+0x1a/0x20
60 [ 7.457166] do_syscall_64+0x5b/0x110
61 [ 7.457210] entry_SYSCALL_64_after_hwframe+0x49/0xbe
62
63 Signed-off-by: Brad Love <brad@nextdimension.cc>
64 Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
65 Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
66 Signed-off-by: Sasha Levin <sashal@kernel.org>
67 ---
68 drivers/media/usb/au0828/au0828-core.c | 1 -
69 1 file changed, 1 deletion(-)
70
71 diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
72 index cd363a2100d4..257ae0d8cfe2 100644
73 --- a/drivers/media/usb/au0828/au0828-core.c
74 +++ b/drivers/media/usb/au0828/au0828-core.c
75 @@ -629,7 +629,6 @@ static int au0828_usb_probe(struct usb_interface *interface,
76 pr_err("%s() au0282_dev_register failed to register on V4L2\n",
77 __func__);
78 mutex_unlock(&dev->lock);
79 - kfree(dev);
80 goto done;
81 }
82
83 --
84 2.19.1
85