[PATCH] firmware: samsung: acpm: Don't use pdev after putting it in acpm_get_by_node()

Peter Griffin peter.griffin at linaro.org
Wed Nov 25 13:05:46 PST 2026


On Mon, 23 Nov 2026 at 00:46, Suyuan Wang via B4 Relay
<devnull+shyckless.gmail.com at kernel.org> wrote:
>
> From: Suyuan Wang <stevewong at 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 at vger.kernel.org
> Co-developed-by: Kaixuan Li <kaixuan.li at ntu.edu.sg>
> Signed-off-by: Kaixuan Li <kaixuan.li at ntu.edu.sg>
> Signed-off-by: Suyuan Wang <stevewong at hust.edu.cn>
> ---

Reviewed-by: Peter Griffin <peter.griffin at linaro.org>

> 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);
>         }
>
>
>
>
>



More information about the linux-arm-kernel mailing list