From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, John Garry <john.garry@huawei.com>,
Wei Xu <xuwei5@hisilicon.com>
Subject: [PATCH 4.19 77/93] bus: hisi_lpc: Add .remove method to avoid driver unbind crash
Date: Wed, 4 Sep 2019 19:54:19 +0200 [thread overview]
Message-ID: <20190904175309.744840990@linuxfoundation.org> (raw)
In-Reply-To: <20190904175302.845828956@linuxfoundation.org>
From: John Garry <john.garry@huawei.com>
commit 10e62b47973b0b0ceda076255bcb147b83e20517 upstream.
The original driver author seemed to be under the impression that a driver
cannot be removed if it does not have a .remove method. Or maybe if it is
a built-in platform driver.
This is not true. This crash can be created:
root@ubuntu:/sys/bus/platform/drivers/hisi-lpc# echo HISI0191\:00 > unbind
root@ubuntu:/sys/bus/platform/drivers/hisi-lpc# ipmitool raw 6 1
Unable to handle kernel paging request at virtual address ffff000010035010
Mem abort info:
ESR = 0x96000047
Exception class = DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
Data abort info:
ISV = 0, ISS = 0x00000047
CM = 0, WnR = 1
swapper pgtable: 4k pages, 48-bit VAs, pgdp=000000000118b000
[ffff000010035010] pgd=0000041ffbfff003, pud=0000041ffbffe003, pmd=0000041ffbffd003, pte=0000000000000000
Internal error: Oops: 96000047 [#1] PREEMPT SMP
Modules linked in:
CPU: 17 PID: 1473 Comm: ipmitool Not tainted 5.2.0-rc5-00003-gf68c53b414a3-dirty #198
Hardware name: Huawei Taishan 2280 /D05, BIOS Hisilicon D05 IT21 Nemo 2.0 RC0 04/18/2018
pstate: 20000085 (nzCv daIf -PAN -UAO)
pc : hisi_lpc_target_in+0x7c/0x120
lr : hisi_lpc_target_in+0x70/0x120
sp : ffff00001efe3930
x29: ffff00001efe3930 x28: ffff841f9f599200
x27: 0000000000000002 x26: 0000000000000000
x25: 0000000000000080 x24: 00000000000000e4
x23: 0000000000000000 x22: 0000000000000064
x21: ffff801fb667d280 x20: 0000000000000001
x19: ffff00001efe39ac x18: 0000000000000000
x17: 0000000000000000 x16: 0000000000000000
x15: 0000000000000000 x14: 0000000000000000
x13: 0000000000000000 x12: 0000000000000000
x11: 0000000000000000 x10: 0000000000000000
x9 : 0000000000000000 x8 : ffff841febe60340
x7 : ffff801fb55c52e8 x6 : 0000000000000000
x5 : 0000000000ffc0e3 x4 : 0000000000000001
x3 : ffff801fb667d280 x2 : 0000000000000001
x1 : ffff000010035010 x0 : ffff000010035000
Call trace:
hisi_lpc_target_in+0x7c/0x120
hisi_lpc_comm_in+0x88/0x98
logic_inb+0x5c/0xb8
port_inb+0x18/0x20
bt_event+0x38/0x808
smi_event_handler+0x4c/0x5a0
check_start_timer_thread.part.4+0x40/0x58
sender+0x78/0x88
smi_send.isra.6+0x94/0x108
i_ipmi_request+0x2c4/0x8f8
ipmi_request_settime+0x124/0x160
handle_send_req+0x19c/0x208
ipmi_ioctl+0x2c0/0x990
do_vfs_ioctl+0xb8/0x8f8
ksys_ioctl+0x80/0xb8
__arm64_sys_ioctl+0x1c/0x28
el0_svc_common.constprop.0+0x64/0x160
el0_svc_handler+0x28/0x78
el0_svc+0x8/0xc
Code: 941d1511 aa0003f9 f94006a0 91004001 (b9000034)
---[ end trace aa842b86af7069e4 ]---
The problem here is that the host goes away but the associated logical PIO
region remains registered, as do the children devices.
Fix by adding a .remove method to tidy-up by removing the child devices
and unregistering the logical PIO region.
Cc: stable@vger.kernel.org
Fixes: adf38bb0b595 ("HISI LPC: Support the LPC host on Hip06/Hip07 with DT bindings")
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Wei Xu <xuwei5@hisilicon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/bus/hisi_lpc.c | 38 ++++++++++++++++++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
--- a/drivers/bus/hisi_lpc.c
+++ b/drivers/bus/hisi_lpc.c
@@ -456,6 +456,17 @@ struct hisi_lpc_acpi_cell {
size_t pdata_size;
};
+static void hisi_lpc_acpi_remove(struct device *hostdev)
+{
+ struct acpi_device *adev = ACPI_COMPANION(hostdev);
+ struct acpi_device *child;
+
+ device_for_each_child(hostdev, NULL, hisi_lpc_acpi_remove_subdev);
+
+ list_for_each_entry(child, &adev->children, node)
+ acpi_device_clear_enumerated(child);
+}
+
/*
* hisi_lpc_acpi_probe - probe children for ACPI FW
* @hostdev: LPC host device pointer
@@ -556,8 +567,7 @@ static int hisi_lpc_acpi_probe(struct de
return 0;
fail:
- device_for_each_child(hostdev, NULL,
- hisi_lpc_acpi_remove_subdev);
+ hisi_lpc_acpi_remove(hostdev);
return ret;
}
@@ -570,6 +580,10 @@ static int hisi_lpc_acpi_probe(struct de
{
return -ENODEV;
}
+
+static void hisi_lpc_acpi_remove(struct device *hostdev)
+{
+}
#endif // CONFIG_ACPI
/*
@@ -627,6 +641,8 @@ static int hisi_lpc_probe(struct platfor
return ret;
}
+ dev_set_drvdata(dev, lpcdev);
+
io_end = lpcdev->io_host->io_start + lpcdev->io_host->size;
dev_info(dev, "registered range [%pa - %pa]\n",
&lpcdev->io_host->io_start, &io_end);
@@ -634,6 +650,23 @@ static int hisi_lpc_probe(struct platfor
return ret;
}
+static int hisi_lpc_remove(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct acpi_device *acpi_device = ACPI_COMPANION(dev);
+ struct hisi_lpc_dev *lpcdev = dev_get_drvdata(dev);
+ struct logic_pio_hwaddr *range = lpcdev->io_host;
+
+ if (acpi_device)
+ hisi_lpc_acpi_remove(dev);
+ else
+ of_platform_depopulate(dev);
+
+ logic_pio_unregister_range(range);
+
+ return 0;
+}
+
static const struct of_device_id hisi_lpc_of_match[] = {
{ .compatible = "hisilicon,hip06-lpc", },
{ .compatible = "hisilicon,hip07-lpc", },
@@ -647,5 +680,6 @@ static struct platform_driver hisi_lpc_d
.acpi_match_table = ACPI_PTR(hisi_lpc_acpi_match),
},
.probe = hisi_lpc_probe,
+ .remove = hisi_lpc_remove,
};
builtin_platform_driver(hisi_lpc_driver);
next prev parent reply other threads:[~2019-09-04 18:08 UTC|newest]
Thread overview: 102+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-04 17:53 [PATCH 4.19 00/93] 4.19.70-stable review Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 01/93] dmaengine: ste_dma40: fix unneeded variable warning Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 02/93] nvme-multipath: revalidate nvme_ns_head gendisk in nvme_validate_ns Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 03/93] afs: Fix the CB.ProbeUuid service handler to reply correctly Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 04/93] afs: Fix loop index mixup in afs_deliver_vl_get_entry_by_name_u() Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 05/93] fs: afs: Fix a possible null-pointer dereference in afs_put_read() Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 06/93] afs: Only update d_fsdata if different in afs_d_revalidate() Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 07/93] nvmet-loop: Flush nvme_delete_wq when removing the port Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 08/93] nvme: fix a possible deadlock when passthru commands sent to a multipath device Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 09/93] nvme-pci: Fix async probe remove race Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 10/93] soundwire: cadence_master: fix register definition for SLAVE_STATE Greg Kroah-Hartman
2019-09-06 13:54 ` Pavel Machek
2019-09-04 17:53 ` [PATCH 4.19 11/93] soundwire: cadence_master: fix definitions for INTSTAT0/1 Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 12/93] auxdisplay: panel: need to delete scan_timer when misc_register fails in panel_attach Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 13/93] dmaengine: stm32-mdma: Fix a possible null-pointer dereference in stm32_mdma_irq_handler() Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 14/93] omap-dma/omap_vout_vrfb: fix off-by-one fi value Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 15/93] iommu/dma: Handle SG length overflow better Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 16/93] usb: gadget: composite: Clear "suspended" on reset/disconnect Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 17/93] usb: gadget: mass_storage: Fix races between fsg_disable and fsg_set_alt Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 18/93] xen/blkback: fix memory leaks Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 19/93] arm64: cpufeature: Dont treat granule sizes as strict Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 20/93] i2c: rcar: avoid race when unregistering slave client Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 21/93] i2c: emev2: " Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 22/93] drm/ast: Fixed reboot test may cause system hanged Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 23/93] usb: host: fotg2: restart hcd after port reset Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 24/93] tools: hv: fixed Python pep8/flake8 warnings for lsvmbus Greg Kroah-Hartman
2019-09-06 13:52 ` Pavel Machek
2019-09-04 17:53 ` [PATCH 4.19 25/93] tools: hv: fix KVP and VSS daemons exit code Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 26/93] drm/i915: fix broadwell EU computation Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 27/93] watchdog: bcm2835_wdt: Fix module autoload Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 28/93] drm/bridge: tfp410: fix memleak in get_modes() Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 29/93] scsi: ufs: Fix RX_TERMINATION_FORCE_ENABLE define value Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 30/93] drm/tilcdc: Register cpufreq notifier after we have initialized crtc Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 31/93] net/tls: Fixed return value when tls_complete_pending_work() fails Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 32/93] net/tls: swap sk_write_space on close Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 33/93] net: tls, fix sk_write_space NULL write when tx disabled Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 34/93] ipv6/addrconf: allow adding multicast addr if IFA_F_MCAUTOJOIN is set Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 35/93] ipv6: Default fib6_type to RTN_UNICAST when not set Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 36/93] net/smc: make sure EPOLLOUT is raised Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 37/93] tcp: make sure EPOLLOUT wont be missed Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 38/93] ipv4/icmp: fix rt dst dev null pointer dereference Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 39/93] mm/zsmalloc.c: fix build when CONFIG_COMPACTION=n Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 40/93] ALSA: usb-audio: Check mixer unit bitmap yet more strictly Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 41/93] ALSA: line6: Fix memory leak at line6_init_pcm() error path Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 42/93] ALSA: hda - Fixes inverted Conexant GPIO mic mute led Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 43/93] ALSA: seq: Fix potential concurrent access to the deleted pool Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 44/93] ALSA: usb-audio: Fix invalid NULL check in snd_emuusb_set_samplerate() Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 45/93] ALSA: usb-audio: Add implicit fb quirk for Behringer UFX1604 Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 46/93] kvm: x86: skip populating logical dest map if apic is not sw enabled Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 47/93] KVM: x86: Dont update RIP or do single-step on faulting emulation Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 48/93] uprobes/x86: Fix detection of 32-bit user mode Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 49/93] x86/apic: Do not initialize LDR and DFR for bigsmp Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 50/93] x86/apic: Include the LDR when clearing out APIC registers Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 51/93] ftrace: Fix NULL pointer dereference in t_probe_next() Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 52/93] ftrace: Check for successful allocation of hash Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 53/93] ftrace: Check for empty hash and comment the race with registering probes Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 54/93] usb-storage: Add new JMS567 revision to unusual_devs Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 55/93] USB: cdc-wdm: fix race between write and disconnect due to flag abuse Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 56/93] usb: hcd: use managed device resources Greg Kroah-Hartman
2019-09-04 17:53 ` [PATCH 4.19 57/93] usb: chipidea: udc: dont do hardware access if gadget has stopped Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 58/93] usb: host: ohci: fix a race condition between shutdown and irq Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 59/93] usb: host: xhci: rcar: Fix typo in compatible string matching Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 60/93] USB: storage: ums-realtek: Update module parameter description for auto_delink_en Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 61/93] USB: storage: ums-realtek: Whitelist auto-delink support Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 62/93] mei: me: add Tiger Lake point LP device ID Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 63/93] mmc: sdhci-of-at91: add quirk for broken HS200 Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 64/93] mmc: core: Fix init of SD cards reporting an invalid VDD range Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 65/93] stm class: Fix a double free of stm_source_device Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 66/93] intel_th: pci: Add support for another Lewisburg PCH Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 67/93] intel_th: pci: Add Tiger Lake support Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 68/93] typec: tcpm: fix a typo in the comparison of pdo_max_voltage Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 69/93] fsi: scom: Dont abort operations for minor errors Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 70/93] lib: logic_pio: Fix RCU usage Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 71/93] lib: logic_pio: Avoid possible overlap for unregistering regions Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 72/93] lib: logic_pio: Add logic_pio_unregister_range() Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 73/93] drm/amdgpu: Add APTX quirk for Dell Latitude 5495 Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 74/93] drm/i915: Dont deballoon unused ggtt drm_mm_node in linux guest Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 75/93] drm/i915: Call dma_set_max_seg_size() in i915_driver_hw_probe() Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 76/93] bus: hisi_lpc: Unregister logical PIO range to avoid potential use-after-free Greg Kroah-Hartman
2019-09-04 17:54 ` Greg Kroah-Hartman [this message]
2019-09-04 17:54 ` [PATCH 4.19 78/93] VMCI: Release resource if the work is already queued Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 79/93] crypto: ccp - Ignore unconfigured CCP device on suspend/resume Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 80/93] Revert "cfg80211: fix processing world regdomain when non modular" Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 81/93] mac80211: fix possible sta leak Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 82/93] mac80211: Dont memset RXCB prior to PAE intercept Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 83/93] mac80211: Correctly set noencrypt for PAE frames Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 84/93] KVM: PPC: Book3S: Fix incorrect guest-to-user-translation error handling Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 85/93] KVM: arm/arm64: vgic: Fix potential deadlock when ap_list is long Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 86/93] KVM: arm/arm64: vgic-v2: Handle SGI bits in GICD_I{S,C}PENDR0 as WI Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 87/93] NFS: Clean up list moves of struct nfs_page Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 88/93] NFSv4/pnfs: Fix a page lock leak in nfs_pageio_resend() Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 89/93] NFS: Pass error information to the pgio error cleanup routine Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 90/93] NFS: Ensure O_DIRECT reports an error if the bytes read/written is 0 Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 91/93] i2c: piix4: Fix port selection for AMD Family 16h Model 30h Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 92/93] x86/ptrace: fix up botched merge of spectrev1 fix Greg Kroah-Hartman
2019-09-04 17:54 ` [PATCH 4.19 93/93] mt76: mt76x0u: do not reset radio on resume Greg Kroah-Hartman
2019-09-04 22:18 ` [PATCH 4.19 00/93] 4.19.70-stable review kernelci.org bot
2019-09-05 14:57 ` shuah
2019-09-05 16:56 ` Guenter Roeck
2019-09-05 17:28 ` Daniel Díaz
2019-09-05 19:51 ` Kelsey Skunberg
2019-09-06 7:37 ` Jon Hunter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190904175309.744840990@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=john.garry@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=xuwei5@hisilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).