arm/mm: Fix refcount leak bugs in cache
PATCH v3 1/1 arm/mm: Fix refcount leak bugs in cache
In feroceon_of_init() and tauros2_init(), of_find_matching_node() will return a node pointer with refcount incremented. We should use of_node_put() in fail path or when it is not used anymore.
---
changelog:
v3: (1) merge arm/mm leak bugs (2) fix bugs intro-ed by v2
v2: (1) use real name (2) normalize coding style
v1: (1) fix leak bug
arch/arm/mm/cache-feroceon-l2.c | 6 +++++- arch/arm/mm/cache-tauros2.c | 1 + 2 files changed, 6 insertions(+), 1 deletion(-)
arch/arm/mm/cache-feroceon-l2.c +5 -1
@@ -376,8 +376,10 @@ int __init feroceon_of_init(void) node =of_find_matching_node (NULL , feroceon_ids);if (node &&of_device_is_compatible (node,"marvell,kirkwood-cache" )) { base =of_iomap (node,0 ); -if (!base) +if (!base) { +of_node_put (node);return -ENOMEM ; + }if (l2_wt_override)writel (readl (base) |L2_WRITETHROUGH_KIRKWOOD , base);
@@ -385,6 +387,8 @@ int __init feroceon_of_init(void)writel (readl (base) & ~L2_WRITETHROUGH_KIRKWOOD , base); } +of_node_put (node); +feroceon_l2_init (l2_wt_override);return 0 ;
arch/arm/mm/cache-tauros2.c +1 -0
@@ -294,6 +294,7 @@ void __init tauros2_init(unsigned int features)pr_info ("Not found marvell,tauros2-cache, disable it\n" ); }else { ret =of_property_read_u32 (node,"marvell,tauros2-cache-features" , &f); +of_node_put (node);if (ret) {pr_info ("Not found marvell,tauros-cache-features property, " "disable extra features\n" );
Signature · 1 line
2.25.1
Quoted 4 lines · Liang He
In
feroceon_of_init()andtauros2_init(),of_find_matching_node()will return a node pointer with refcount incremented. We should useof_node_put()in fail path or when it is not used anymore.
Quoted 8 lines
Signed-off-by Liang He <[email protected]>---
changelog:v3: (1) merge arm/mm leak bugs (2) fix bugs intro-ed by v2
v2: (1) use real name (2) normalize coding style
v1: (1) fix leak bug
Before applying the patch please check it carefully. Previous evidence [1][2] suggests that not it was not even compiled.
[1] https://lore.kernel.org/all/[email protected]/
[2]
https://lore.kernel.org/all/[email protected]/
Best regards,
Krzysztof
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel