soc: qcom: llcc-qcom: Unregister the EDAC device on unbind
Subsystems (3)
PATCH 1/1 soc: qcom: llcc-qcom: Unregister the EDAC device on unbind
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.
---
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(-)
drivers/soc/qcom/llcc-qcom.c +12 -1
@@ -5749,6 +5749,11 @@ static struct regmap *qcom_llcc_init_mmio(struct platform_device *pdev, u8 indexreturn 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
Quoted 11 lines · Yige Jiang
qcom_llcc_probe()registers theqcom_llcc_edacplatform 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.
[...]
Applied, thanks!
[1/1] soc: qcom: llcc-qcom: Unregister the EDAC device on unbind
commit: 1e5bbf63105d0b367efc6df0bf87c7fde0f91995
Best regards,
Signature · 1 line
Bjorn Andersson <[email protected]>