]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
firmware: meson_sm: fix device leak at probe
authorJohan Hovold <johan@kernel.org>
Fri, 25 Jul 2025 07:40:19 +0000 (09:40 +0200)
committerNeil Armstrong <neil.armstrong@linaro.org>
Thu, 4 Sep 2025 13:13:53 +0000 (15:13 +0200)
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>
drivers/firmware/meson/meson_sm.c

index f25a9746249b6093a0de21fb9b56cd7f767ccdf3..3ab67aaa9e5da9da7bd7ee66bf9da4f922d39d10 100644 (file)
@@ -232,11 +232,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);