From: Suyuan Wang via B4 Relay <devnull+shyckless.gmail.com@kernel.org>
To: tudor.ambarus@linaro.org, krzk@kernel.org, peter.griffin@linaro.org
Cc: alim.akhtar@samsung.com, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org
Subject: [PATCH] firmware: samsung: acpm: Don't use pdev after putting it in acpm_get_by_node()
Date: Mon, 23 Nov 2026 00:46:28 +0000 [thread overview]
Message-ID: <20261123-exynos-acpm-put-v1-1-447097ce7998@gmail.com> (raw)
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);
}
reply other threads:[~2026-11-23 0:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261123-exynos-acpm-put-v1-1-447097ce7998@gmail.com \
--to=devnull+shyckless.gmail.com@kernel.org \
--cc=alim.akhtar@samsung.com \
--cc=krzk@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=peter.griffin@linaro.org \
--cc=shyckless@gmail.com \
--cc=tudor.ambarus@linaro.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
all inboxes | Powered by JetHome®