[PATCH] soc: qcom: llcc-qcom: Unregister the EDAC device on unbind

From: Yige Jiang

Date: Wed Dec 02 2026 - 14:15:57 EST


qcom_llcc_probe() registers the qcom_llcc_edac platform device but
keeps the returned pointer only in a local variable. Nothing unregisters
the child when the LLCC driver is unbound.

The child's platform data contains pointers to the LLCC device's
managed regmaps. Those are freed on unbind while the EDAC device
remains bound, so its polling work or interrupt handler can access
freed memory. The remaining child also prevents its replacement from
being registered on a subsequent bind.

Add a devres action immediately after registering the EDAC device.
This unregisters the child before the older regmap resources are
released, and also handles failure to allocate the action.

Fixes: c081f3060fab ("soc: qcom: Add support to register LLCC EDAC driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Yige Jiang <yigejiang86@xxxxxxxxx>
---
Based on Qualcomm for-next as merged in next-20261201.
Compile-tested on next-20261104: arm64, GCC 14.2.0, W=1;
baseline and patched objects built without warnings.
Both CONFIG_QCOM_LLCC=y and =m were checked.
The code changes are the same as in that build.
No hardware or runtime test was performed.

drivers/soc/qcom/llcc-qcom.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/llcc-qcom.c b/drivers/soc/qcom/llcc-qcom.c
index 166ad2e996f745c97655d4e92e4e034f8771f202..37baaeec55246b187ef498ff0fbbe4bc90434334 100644
--- a/drivers/soc/qcom/llcc-qcom.c
+++ b/drivers/soc/qcom/llcc-qcom.c
@@ -5749,6 +5749,11 @@ static struct regmap *qcom_llcc_init_mmio(struct platform_device *pdev, u8 index
return devm_regmap_init_mmio(&pdev->dev, base, &llcc_regmap_config);
}

+static void qcom_llcc_unregister_edac(void *data)
+{
+ platform_device_unregister(data);
+}
+
static int qcom_llcc_probe(struct platform_device *pdev)
{
u32 num_banks;
@@ -5889,8 +5894,14 @@ static int qcom_llcc_probe(struct platform_device *pdev)
llcc_edac = platform_device_register_data(&pdev->dev,
"qcom_llcc_edac", -1, drv_data,
sizeof(*drv_data));
- if (IS_ERR(llcc_edac))
+ if (IS_ERR(llcc_edac)) {
dev_err(dev, "Failed to register LLCC EDAC driver\n");
+ } else {
+ ret = devm_add_action_or_reset(dev, qcom_llcc_unregister_edac,
+ llcc_edac);
+ if (ret)
+ goto err;
+ }
}

platform_set_drvdata(pdev, drv_data);

base-commit: ef922b721a5e99348fc1f5801fdeb427ee14ee9f