summaryrefslogtreecommitdiff
path: root/drivers/firmware
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2025-07-25 09:40:19 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-19 16:30:47 +0200
commitdbcbac8c47cbb9afe9853c18cad8f9e6336c2548 (patch)
tree978589239c0660ce97eda76829309e9a19ca0c63 /drivers/firmware
parent135eacbb111f37953687533adf067cd0351b5e8c (diff)
downloadlinux-dbcbac8c47cbb9afe9853c18cad8f9e6336c2548.tar.gz
linux-dbcbac8c47cbb9afe9853c18cad8f9e6336c2548.tar.bz2
linux-dbcbac8c47cbb9afe9853c18cad8f9e6336c2548.zip
firmware: meson_sm: fix device leak at probe
commit 8ece3173f87df03935906d0c612c2aeda9db92ca 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: 8cde3c2153e8 ("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>
Diffstat (limited to 'drivers/firmware')
-rw-r--r--drivers/firmware/meson/meson_sm.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/firmware/meson/meson_sm.c b/drivers/firmware/meson/meson_sm.c
index 9a2656d73600..b39f395c077e 100644
--- a/drivers/firmware/meson/meson_sm.c
+++ b/drivers/firmware/meson/meson_sm.c
@@ -225,11 +225,16 @@ EXPORT_SYMBOL(meson_sm_call_write);
struct meson_sm_firmware *meson_sm_get(struct device_node *sm_node)
{
struct platform_device *pdev = of_find_device_by_node(sm_node);
+ struct meson_sm_firmware *fw;
if (!pdev)
return NULL;
- return platform_get_drvdata(pdev);
+ fw = platform_get_drvdata(pdev);
+
+ put_device(&pdev->dev);
+
+ return fw;
}
EXPORT_SYMBOL_GPL(meson_sm_get);