Commit 3c85234b authored by Felix Gu's avatar Felix Gu Committed by Conor Dooley
Browse files

cache: starfive: fix device node leak in starlink_cache_init()



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: cabff60c ("cache: Add StarFive StarLink cache management")
Signed-off-by: default avatarFelix Gu <ustc.gu@gmail.com>
Reviewed-by: default avatarJonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: default avatarConor Dooley <conor.dooley@microchip.com>
parent ff4b6bf7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -102,11 +102,11 @@ static const struct of_device_id starlink_cache_ids[] = {

static int __init starlink_cache_init(void)
{
	struct device_node *np;
	u32 block_size;
	int ret;

	np = of_find_matching_node(NULL, starlink_cache_ids);
	struct device_node *np __free(device_node) =
		of_find_matching_node(NULL, starlink_cache_ids);
	if (!of_device_is_available(np))
		return -ENODEV;