[PATCH] firmware: samsung: acpm: Don't use pdev after putting it in acpm_get_by_node()
From: Suyuan Wang via B4 Relay
Date: Sun Nov 22 2026 - 19:47:09 EST
From: Suyuan Wang <stevewong@xxxxxxxxxxx>
When device_link_add() fails, acpm_get_by_node() drops the reference to
the ACPM platform device and only then reads its driver to drop the
module reference:
platform_device_put(pdev);
module_put(pdev->dev.driver->owner);
The reference from of_find_device_by_node() is what keeps pdev around
here, so pdev must not be used after the put.
Drop the module reference before the device reference, as
acpm_handle_put() already does.
Found with a static analysis tool and checked by hand.
Fixes: a88927b534ba ("firmware: add Exynos ACPM protocol driver")
Cc: stable@xxxxxxxxxxxxxxx
Co-developed-by: Kaixuan Li <kaixuan.li@xxxxxxxxxx>
Signed-off-by: Kaixuan Li <kaixuan.li@xxxxxxxxxx>
Signed-off-by: Suyuan Wang <stevewong@xxxxxxxxxxx>
---
Compile tested on arm64 (W=1). I don't have the hardware.
---
drivers/firmware/samsung/exynos-acpm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/firmware/samsung/exynos-acpm.c b/drivers/firmware/samsung/exynos-acpm.c
index a575caf871b9..15d2f708b0c7 100644
--- a/drivers/firmware/samsung/exynos-acpm.c
+++ b/drivers/firmware/samsung/exynos-acpm.c
@@ -816,8 +816,8 @@ static struct acpm_handle *acpm_get_by_node(struct device *dev,
dev_err(&pdev->dev,
"Failed to create device link to consumer %s.\n",
dev_name(dev));
- platform_device_put(pdev);
module_put(pdev->dev.driver->owner);
+ platform_device_put(pdev);
return ERR_PTR(-EINVAL);
}