]> git.baikalelectronics.ru Git - kernel.git/commitdiff
memory: pl353-smc: Fix refcount leak bug in pl353_smc_probe()
authorLiang He <windhl@126.com>
Sat, 16 Jul 2022 03:13:24 +0000 (11:13 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 11:22:31 +0000 (13:22 +0200)
[ Upstream commit 0d43c4f94931456676e708f4f52e507cd2b0bba7 ]

The break of for_each_available_child_of_node() needs a
corresponding of_node_put() when the reference 'child' is not
used anymore. Here we do not need to call of_node_put() in
fail path as '!match' means no break.

While the of_platform_device_create() will created a new
reference by 'child' but it has considered the refcounting.

Fixes: 7f4c905b9719 ("memory: pl353: Add driver for arm pl353 static memory controller")
Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20220716031324.447680-1-windhl@126.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/memory/pl353-smc.c

index cc01979780d87eb04fffdaae933d5ecd240bac16..322d7ead00315110bae214b016a01a4d368b0d78 100644 (file)
@@ -416,6 +416,7 @@ static int pl353_smc_probe(struct amba_device *adev, const struct amba_id *id)
        if (init)
                init(adev, child);
        of_platform_device_create(child, NULL, &adev->dev);
+       of_node_put(child);
 
        return 0;