firmware: meson_sm: fix device leak at probe

commit 8ece3173f8 upstream.

Make sure to drop the reference to the secure monitor device taken by
of_find_device_by_node() when looking up its driver data on behalf of
other drivers (e.g. during probe).

Note that holding a reference to the platform device does not prevent
its driver data from going away so there is no point in keeping the
reference after the helper returns.

Fixes: 8cde3c2153 ("firmware: meson_sm: Rework driver as a proper platform driver")
Cc: stable@vger.kernel.org	# 5.5
Cc: Carlo Caione <ccaione@baylibre.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://lore.kernel.org/r/20250725074019.8765-1-johan@kernel.org
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Johan Hovold
2025-07-25 09:40:19 +02:00
committed by Greg Kroah-Hartman
parent 9a5aad7d6e
commit 6afea664e9

View File

@@ -232,11 +232,16 @@ EXPORT_SYMBOL(meson_sm_call_write);
struct meson_sm_firmware *meson_sm_get(struct device_node *sm_node) struct meson_sm_firmware *meson_sm_get(struct device_node *sm_node)
{ {
struct platform_device *pdev = of_find_device_by_node(sm_node); struct platform_device *pdev = of_find_device_by_node(sm_node);
struct meson_sm_firmware *fw;
if (!pdev) if (!pdev)
return NULL; return NULL;
return platform_get_drvdata(pdev); fw = platform_get_drvdata(pdev);
put_device(&pdev->dev);
return fw;
} }
EXPORT_SYMBOL_GPL(meson_sm_get); EXPORT_SYMBOL_GPL(meson_sm_get);