Skip to content
/ linux Public

Commit 640452d

Browse files
outman119gregkh
authored andcommitted
cache: ax45mp: Fix device node reference leak in ax45mp_cache_init()
[ Upstream commit 0528a34 ] In ax45mp_cache_init(), of_find_matching_node() returns a device node with an incremented reference count that must be released with of_node_put(). The current code fails to call of_node_put() which causes a reference leak. Use the __free(device_node) attribute to ensure automatic cleanup when the variable goes out of scope. Fixes: d34599b ("cache: Add L2 cache management for Andes AX45MP RISC-V core") Signed-off-by: Felix Gu <ustc.gu@gmail.com> Signed-off-by: Conor Dooley <conor.dooley@microchip.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 606fcf9 commit 640452d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/cache/ax45mp_cache.c

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

179179
static int __init ax45mp_cache_init(void)
180180
{
181-
struct device_node *np;
182181
struct resource res;
183182
int ret;
184183

185-
np = of_find_matching_node(NULL, ax45mp_cache_ids);
184+
struct device_node *np __free(device_node) =
185+
of_find_matching_node(NULL, ax45mp_cache_ids);
186186
if (!of_device_is_available(np))
187187
return -ENODEV;
188188

0 commit comments

Comments
 (0)