Skip to content
/ linux Public

Commit 606fcf9

Browse files
outman119gregkh
authored andcommitted
cache: starfive: fix device node leak in starlink_cache_init()
[ Upstream commit 3c85234 ] of_find_matching_node() returns a device_node with refcount incremented. Use __free(device_node) attribute to automatically call of_node_put() when the variable goes out of scope, preventing the refcount leak. Fixes: cabff60 ("cache: Add StarFive StarLink cache management") Signed-off-by: Felix Gu <ustc.gu@gmail.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Signed-off-by: Conor Dooley <conor.dooley@microchip.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e3dd5cf commit 606fcf9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/cache/starfive_starlink_cache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ static const struct of_device_id starlink_cache_ids[] = {
102102

103103
static int __init starlink_cache_init(void)
104104
{
105-
struct device_node *np;
106105
u32 block_size;
107106
int ret;
108107

109-
np = of_find_matching_node(NULL, starlink_cache_ids);
108+
struct device_node *np __free(device_node) =
109+
of_find_matching_node(NULL, starlink_cache_ids);
110110
if (!of_device_is_available(np))
111111
return -ENODEV;
112112

0 commit comments

Comments
 (0)