]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/5.0.4/acpi-device_sysfs-avoid-of-modalias-creation-for-removed-device.patch
Linux 5.0.4
[thirdparty/kernel/stable-queue.git] / releases / 5.0.4 / acpi-device_sysfs-avoid-of-modalias-creation-for-removed-device.patch
1 From f16eb8a4b096514ac06fb25bf599dcc792899b3d Mon Sep 17 00:00:00 2001
2 From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 Date: Mon, 11 Mar 2019 18:41:03 +0200
4 Subject: ACPI / device_sysfs: Avoid OF modalias creation for removed device
5
6 From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
7
8 commit f16eb8a4b096514ac06fb25bf599dcc792899b3d upstream.
9
10 If SSDT overlay is loaded via ConfigFS and then unloaded the device,
11 we would like to have OF modalias for, already gone. Thus, acpi_get_name()
12 returns no allocated buffer for such case and kernel crashes afterwards:
13
14 ACPI: Host-directed Dynamic ACPI Table Unload
15 ads7950 spi-PRP0001:00: Dropping the link to regulator.0
16 BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
17 #PF error: [normal kernel read fault]
18 PGD 80000000070d6067 P4D 80000000070d6067 PUD 70d0067 PMD 0
19 Oops: 0000 [#1] SMP PTI
20 CPU: 0 PID: 40 Comm: kworker/u4:2 Not tainted 5.0.0+ #96
21 Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 542 2015.01.21:18.19.48
22 Workqueue: kacpi_hotplug acpi_device_del_work_fn
23 RIP: 0010:create_of_modalias.isra.1+0x4c/0x150
24 Code: 00 00 48 89 44 24 18 31 c0 48 8d 54 24 08 48 c7 44 24 10 00 00 00 00 48 c7 44 24 08 ff ff ff ff e8 7a b0 03 00 48 8b 4c 24 10 <0f> b6 01 84 c0 74 27 48 c7 c7 00 09 f4 a5 0f b6 f0 8d 50 20 f6 04
25 RSP: 0000:ffffa51040297c10 EFLAGS: 00010246
26 RAX: 0000000000001001 RBX: 0000000000000785 RCX: 0000000000000000
27 RDX: 0000000000001001 RSI: 0000000000000286 RDI: ffffa2163dc042e0
28 RBP: ffffa216062b1196 R08: 0000000000001001 R09: ffffa21639873000
29 R10: ffffffffa606761d R11: 0000000000000001 R12: ffffa21639873218
30 R13: ffffa2163deb5060 R14: ffffa216063d1010 R15: 0000000000000000
31 FS: 0000000000000000(0000) GS:ffffa2163e000000(0000) knlGS:0000000000000000
32 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
33 CR2: 0000000000000000 CR3: 0000000007114000 CR4: 00000000001006f0
34 Call Trace:
35 __acpi_device_uevent_modalias+0xb0/0x100
36 spi_uevent+0xd/0x40
37
38 ...
39
40 In order to fix above let create_of_modalias() check the status returned
41 by acpi_get_name() and bail out in case of failure.
42
43 Fixes: 8765c5ba1949 ("ACPI / scan: Rework modalias creation when "compatible" is present")
44 Link: https://bugzilla.kernel.org/show_bug.cgi?id=201381
45 Reported-by: Ferry Toth <fntoth@gmail.com>
46 Tested-by: Ferry Toth<fntoth@gmail.com>
47 Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
48 Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
49 Cc: 4.1+ <stable@vger.kernel.org> # 4.1+
50 Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
51 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
52
53 ---
54 drivers/acpi/device_sysfs.c | 6 +++++-
55 1 file changed, 5 insertions(+), 1 deletion(-)
56
57 --- a/drivers/acpi/device_sysfs.c
58 +++ b/drivers/acpi/device_sysfs.c
59 @@ -202,11 +202,15 @@ static int create_of_modalias(struct acp
60 {
61 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
62 const union acpi_object *of_compatible, *obj;
63 + acpi_status status;
64 int len, count;
65 int i, nval;
66 char *c;
67
68 - acpi_get_name(acpi_dev->handle, ACPI_SINGLE_NAME, &buf);
69 + status = acpi_get_name(acpi_dev->handle, ACPI_SINGLE_NAME, &buf);
70 + if (ACPI_FAILURE(status))
71 + return -ENODEV;
72 +
73 /* DT strings are all in lower case */
74 for (c = buf.pointer; *c != '\0'; c++)
75 *c = tolower(*c);