linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.4 061/102] ACPI: platform: Unregister stale platform devices
Date: Fri, 24 Jan 2020 10:31:02 +0100	[thread overview]
Message-ID: <20200124092815.541731799@linuxfoundation.org> (raw)
In-Reply-To: <20200124092806.004582306@linuxfoundation.org>

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

[ Upstream commit cb0701acfa7e3fe9e919cf2aa2aa939b7fd603c2 ]

When commit 68bdb6773289 ("ACPI: add support for ACPI reconfiguration
notifiers") introduced reconfiguration notifiers, it missed the point
that the ACPI table, which might be loaded and then unloaded via
ConfigFS, could contain devices that were not enumerated by their
parents.

In such cases, the stale platform device is dangling in the system
while the rest of the devices from the same table are already gone.

Introduce acpi_platform_device_remove_notify() notifier that, in
similar way to I²C or SPI buses, unregisters the platform devices
on table removal event.

Fixes: 68bdb6773289 ("ACPI: add support for ACPI reconfiguration notifiers")
Depends-on: 00500147cbd3 ("drivers: Introduce device lookup variants by ACPI_COMPANION device")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
[ rjw: Changelog & function rename ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/acpi/acpi_platform.c | 43 ++++++++++++++++++++++++++++++++++++
 drivers/acpi/scan.c          |  1 +
 2 files changed, 44 insertions(+)

diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index 00ec4f2bf0157..c05050f474cd3 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -31,6 +31,44 @@ static const struct acpi_device_id forbidden_id_list[] = {
 	{"", 0},
 };
 
+static struct platform_device *acpi_platform_device_find_by_companion(struct acpi_device *adev)
+{
+	struct device *dev;
+
+	dev = bus_find_device_by_acpi_dev(&platform_bus_type, adev);
+	return dev ? to_platform_device(dev) : NULL;
+}
+
+static int acpi_platform_device_remove_notify(struct notifier_block *nb,
+					      unsigned long value, void *arg)
+{
+	struct acpi_device *adev = arg;
+	struct platform_device *pdev;
+
+	switch (value) {
+	case ACPI_RECONFIG_DEVICE_ADD:
+		/* Nothing to do here */
+		break;
+	case ACPI_RECONFIG_DEVICE_REMOVE:
+		if (!acpi_device_enumerated(adev))
+			break;
+
+		pdev = acpi_platform_device_find_by_companion(adev);
+		if (!pdev)
+			break;
+
+		platform_device_unregister(pdev);
+		put_device(&pdev->dev);
+		break;
+	}
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block acpi_platform_notifier = {
+	.notifier_call = acpi_platform_device_remove_notify,
+};
+
 static void acpi_platform_fill_resource(struct acpi_device *adev,
 	const struct resource *src, struct resource *dest)
 {
@@ -130,3 +168,8 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
 	return pdev;
 }
 EXPORT_SYMBOL_GPL(acpi_create_platform_device);
+
+void __init acpi_platform_init(void)
+{
+	acpi_reconfig_notifier_register(&acpi_platform_notifier);
+}
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index aad6be5c0af0a..915650bf519f8 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -2174,6 +2174,7 @@ int __init acpi_scan_init(void)
 	acpi_pci_root_init();
 	acpi_pci_link_init();
 	acpi_processor_init();
+	acpi_platform_init();
 	acpi_lpss_init();
 	acpi_apd_init();
 	acpi_cmos_rtc_init();
-- 
2.20.1




  parent reply	other threads:[~2020-01-24  9:40 UTC|newest]

Thread overview: 113+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24  9:30 [PATCH 5.4 000/102] 5.4.15-stable review Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 001/102] drm/i915: Fix pid leak with banned clients Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 002/102] libbpf: Fix compatibility for kernels without need_wakeup Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 003/102] libbpf: Fix memory leak/double free issue Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 004/102] libbpf: Fix potential overflow issue Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 005/102] libbpf: Fix another potential overflow issue in bpf_prog_linfo Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 006/102] libbpf: Make btf__resolve_size logic always check size error condition Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 007/102] libbpf: Fix call relocation offset calculation bug Greg Kroah-Hartman
2020-01-24 13:43   ` Naresh Kamboju
2020-01-24 15:18     ` Sasha Levin
2020-01-24  9:30 ` [PATCH 5.4 008/102] bpf: Force .BTF section start to zero when dumping from vmlinux Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 009/102] samples: bpf: update map definition to new syntax BTF-defined map Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 010/102] samples/bpf: Fix broken xdp_rxq_info due to map order assumptions Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 011/102] ARM: dts: logicpd-torpedo-37xx-devkit-28: Reference new DRM panel Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 012/102] ARM: OMAP2+: Add missing put_device() call in omapdss_init_of() Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 013/102] xfs: Sanity check flags of Q_XQUOTARM call Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 014/102] i2c: stm32f7: rework slave_id allocation Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 015/102] i2c: i2c-stm32f7: fix 10-bits check in slave free id search loop Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 016/102] mfd: intel-lpss: Add default I2C device properties for Gemini Lake Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 017/102] SUNRPC: Fix svcauth_gss_proxy_init() Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 018/102] SUNRPC: Fix backchannel latency metrics Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 019/102] powerpc/security: Fix debugfs data leak on 32-bit Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 020/102] powerpc/pseries: Enable support for ibm,drc-info property Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 021/102] powerpc/kasan: Fix boot failure with RELOCATABLE && FSL_BOOKE Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 022/102] powerpc/archrandom: fix arch_get_random_seed_int() Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 023/102] tipc: reduce sensitive to retransmit failures Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 024/102] tipc: update mons self addr when node addr generated Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 025/102] tipc: fix potential memory leak in __tipc_sendmsg() Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 026/102] tipc: fix wrong socket reference counter after tipc_sk_timeout() returns Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 027/102] tipc: fix wrong timeout input for tipc_wait_for_cond() Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 028/102] net/mlx5e: Fix free peer_flow when refcount is 0 Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 029/102] phy: lantiq: vrx200-pcie: fix error return code in ltq_vrx200_pcie_phy_power_on() Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 030/102] net: phy: broadcom: Fix RGMII delays configuration for BCM54210E Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 031/102] phy: ti: gmii-sel: fix mac tx internal delay for rgmii-rxid Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 032/102] mt76: mt76u: fix endpoint definition order Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 033/102] mt7601u: fix bbp version check in mt7601u_wait_bbp_ready Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 034/102] ice: fix stack leakage Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 035/102] s390/pkey: fix memory leak within _copy_apqns_from_user() Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 036/102] nfsd: depend on CRYPTO_MD5 for legacy client tracking Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 037/102] crypto: amcc - restore CRYPTO_AES dependency Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 038/102] crypto: sun4i-ss - fix big endian issues Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 039/102] perf map: No need to adjust the long name of modules Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 040/102] leds: tlc591xx: update the maximum brightness Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 041/102] soc/tegra: pmc: Fix crashes for hierarchical interrupts Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 042/102] soc: qcom: llcc: Name regmaps to avoid collisions Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 043/102] soc: renesas: Add missing check for non-zero product register address Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 044/102] soc: aspeed: Fix snoop_file_poll()s return type Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 045/102] watchdog: sprd: Fix the incorrect pointer getting from driver data Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 046/102] ipmi: Fix memory leak in __ipmi_bmc_register Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 047/102] sched/core: Further clarify sched_class::set_next_task() Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 048/102] gpiolib: No need to call gpiochip_remove_pin_ranges() twice Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 049/102] rtw88: fix beaconing mode rsvd_page memory violation issue Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 050/102] rtw88: fix error handling when setup efuse info Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 051/102] drm/panfrost: Add missing check for pfdev->regulator Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 052/102] drm: panel-lvds: Potential Oops in probe error handling Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 053/102] drm/amdgpu: remove excess function parameter description Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 054/102] hwrng: omap3-rom - Fix missing clock by probing with device tree Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 055/102] dpaa2-eth: Fix minor bug in ethtool stats reporting Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 056/102] drm/rockchip: Round up _before_ giving to the clock framework Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 057/102] software node: Get reference to parent swnode in get_parent op Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 058/102] PCI: mobiveil: Fix csr_read()/write() build issue Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 059/102] drm: rcar_lvds: Fix color mismatches on R-Car H2 ES2.0 and later Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 060/102] net: netsec: Correct dma sync for XDP_TX frames Greg Kroah-Hartman
2020-01-24  9:31 ` Greg Kroah-Hartman [this message]
2020-01-24  9:31 ` [PATCH 5.4 062/102] pwm: sun4i: Fix incorrect calculation of duty_cycle/period Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 063/102] regulator: bd70528: Add MODULE_ALIAS to allow module auto loading Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 064/102] drm/amdgpu/vi: silence an uninitialized variable warning Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 065/102] power: supply: bd70528: Add MODULE_ALIAS to allow module auto loading Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 066/102] firmware: imx: Remove call to devm_of_platform_populate Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 067/102] libbpf: Dont use kernel-side u32 type in xsk.c Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 068/102] rcu: Fix uninitialized variable in nocb_gp_wait() Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 069/102] dpaa_eth: perform DMA unmapping before read Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 070/102] dpaa_eth: avoid timestamp read on error paths Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 071/102] scsi: ufs: delete redundant function ufshcd_def_desc_sizes() Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 072/102] net: openvswitch: dont unlock mutex when changing the user_features fails Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 073/102] hv_netvsc: flag software created hash value Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 074/102] rt2800: remove errornous duplicate condition Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 075/102] net: neigh: use long type to store jiffies delta Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 076/102] net: axienet: Fix error return code in axienet_probe() Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 077/102] selftests: gen_kselftest_tar.sh: Do not clobber kselftest/ Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 078/102] rtc: bd70528: fix module alias to autoload module Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 079/102] packet: fix data-race in fanout_flow_is_huge() Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 080/102] i2c: stm32f7: report dma error during probe Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 081/102] kselftests: cgroup: Avoid the reuse of fd after it is deallocated Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 082/102] firmware: arm_scmi: Fix doorbell ring logic for !CONFIG_64BIT Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 083/102] mmc: sdio: fix wl1251 vendor id Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 084/102] mmc: core: fix wl1251 sdio quirks Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 085/102] tee: optee: Fix dynamic shm pool allocations Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 086/102] tee: optee: fix device enumeration error handling Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 087/102] workqueue: Add RCU annotation for pwq list walk Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 088/102] SUNRPC: Fix another issue with MIC buffer space Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 089/102] sched/cpufreq: Move the cfs_rq_util_change() call to cpufreq_update_util() Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 090/102] mt76: mt76u: rely on usb_interface instead of usb_dev Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 091/102] dma-direct: dont check swiotlb=force in dma_direct_map_resource Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 092/102] afs: Remove set but not used variables before, after Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 093/102] dmaengine: ti: edma: fix missed failure handling Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 094/102] drm/radeon: fix bad DMA from INTERRUPT_CNTL2 Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 095/102] xdp: Fix cleanup on map free for devmap_hash map type Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 096/102] platform/chrome: wilco_ec: fix use after free issue Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 097/102] block: fix memleak of bio integrity data Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 098/102] s390/qeth: fix dangling IO buffers after halt/clear Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 099/102] net-sysfs: Call dev_hold always in netdev_queue_add_kobject Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 100/102] gpio: aspeed: avoid return type warning Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 101/102] phy/rockchip: inno-hdmi: round clock rate down to closest 1000 Hz Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 102/102] optee: Fix multi page dynamic shm pool alloc Greg Kroah-Hartman
2020-01-24 13:47 ` [PATCH 5.4 000/102] 5.4.15-stable review Naresh Kamboju
2020-01-24 14:52 ` Jon Hunter
2020-01-24 21:46 ` shuah
2020-01-25 13:51   ` Greg Kroah-Hartman
2020-01-24 23:56 ` Guenter Roeck
2020-01-25 13:52   ` Greg Kroah-Hartman
2020-01-25 10:22 ` Naresh Kamboju
2020-01-25 13:52   ` Greg Kroah-Hartman

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=20200124092815.541731799@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /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).