[PATCH] powerpc/sysdev/of_rtc: Fix possible memory leak in of_instantiate_rtc

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE1715d

2 messages, 1 author, 2021-12-27 · open the first message on its own page

[PATCH] powerpc/sysdev/of_rtc: Fix possible memory leak in of_instantiate_rtc

From: He Ying <hidden>
Date: 2021-11-03 01:45:41

If of_address_to_resource() in of_instantiate_rtc() fails, previously
allocated memory res is not freed. Add missing kfree() for it.

Signed-off-by: He Ying <redacted>
---
 arch/powerpc/sysdev/of_rtc.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/sysdev/of_rtc.c b/arch/powerpc/sysdev/of_rtc.c
index 1f408d34a6a7..23b896996c2f 100644
--- a/arch/powerpc/sysdev/of_rtc.c
+++ b/arch/powerpc/sysdev/of_rtc.c
@@ -44,6 +44,7 @@ void __init of_instantiate_rtc(void)
 				printk(KERN_ERR "OF RTC: Error "
 				       "translating resources for %pOF\n",
 				       node);
+				kfree(res);
 				continue;
 			}
 
-- 
2.17.1

Re: [PATCH] powerpc/sysdev/of_rtc: Fix possible memory leak in of_instantiate_rtc

From: He Ying <hidden>
Date: 2021-12-27 03:53:12

Ping. Any ideas about this patch?

在 2021/11/3 9:47, He Ying 写道:
quoted hunk
If of_address_to_resource() in of_instantiate_rtc() fails, previously
allocated memory res is not freed. Add missing kfree() for it.

Signed-off-by: He Ying <redacted>
---
  arch/powerpc/sysdev/of_rtc.c | 1 +
  1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/sysdev/of_rtc.c b/arch/powerpc/sysdev/of_rtc.c
index 1f408d34a6a7..23b896996c2f 100644
--- a/arch/powerpc/sysdev/of_rtc.c
+++ b/arch/powerpc/sysdev/of_rtc.c
@@ -44,6 +44,7 @@ void __init of_instantiate_rtc(void)
  				printk(KERN_ERR "OF RTC: Error "
  				       "translating resources for %pOF\n",
  				       node);
+				kfree(res);
  				continue;
  			}
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help