mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] firmware: samsung: acpm: Don't use pdev after putting it in acpm_get_by_node()
@ 2026-11-23  0:46 Suyuan Wang via B4 Relay
  2026-11-23 13:33 ` Tudor Ambarus
  0 siblings, 1 reply; 2+ messages in thread
From: Suyuan Wang via B4 Relay @ 2026-11-23  0:46 UTC (permalink / raw)
  To: tudor.ambarus, krzk, peter.griffin
  Cc: alim.akhtar, linux-kernel, linux-arm-kernel, linux-samsung-soc

From: Suyuan Wang <stevewong@hust.edu.cn>

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@vger.kernel.org
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
---
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);
 	}
 





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] firmware: samsung: acpm: Don't use pdev after putting it in acpm_get_by_node()
  2026-11-23  0:46 [PATCH] firmware: samsung: acpm: Don't use pdev after putting it in acpm_get_by_node() Suyuan Wang via B4 Relay
@ 2026-11-23 13:33 ` Tudor Ambarus
  0 siblings, 0 replies; 2+ messages in thread
From: Tudor Ambarus @ 2026-11-23 13:33 UTC (permalink / raw)
  To: shyckless, krzk, peter.griffin
  Cc: alim.akhtar, linux-kernel, linux-arm-kernel, linux-samsung-soc


Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-23 13:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23  0:46 [PATCH] firmware: samsung: acpm: Don't use pdev after putting it in acpm_get_by_node() Suyuan Wang via B4 Relay
2026-11-23 13:33 ` Tudor Ambarus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®