LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/pseries: fix memory leak on krealloc failure in papr_init
@ 2026-06-14 14:23 Thorsten Blum
  2026-07-21  8:15 ` Madhavan Srinivasan
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-06-14 14:23 UTC (permalink / raw)
  To: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Kees Cook, Pratik R. Sampat
  Cc: Thorsten Blum, stable, linuxppc-dev, linux-kernel

When krealloc() fails, free the original esi_buf before returning to
avoid a memory leak.

Fixes: 3c14b73454cf ("powerpc/pseries: Interface to represent PAPR firmware attributes")
Cc: stable@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 arch/powerpc/platforms/pseries/papr_platform_attributes.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/papr_platform_attributes.c b/arch/powerpc/platforms/pseries/papr_platform_attributes.c
index ff8adda02341..aacdaa1ebf63 100644
--- a/arch/powerpc/platforms/pseries/papr_platform_attributes.c
+++ b/arch/powerpc/platforms/pseries/papr_platform_attributes.c
@@ -271,11 +271,9 @@ static int __init papr_init(void)
 		esi_buf_size = ESI_HDR_SIZE + (CURR_MAX_ESI_ATTRS * max_esi_attrs);
 
 		temp_esi_buf = krealloc(esi_buf, esi_buf_size, GFP_KERNEL);
-		if (temp_esi_buf)
-			esi_buf = temp_esi_buf;
-		else
-			return -ENOMEM;
-
+		if (!temp_esi_buf)
+			goto out_free_esi_buf;
+		esi_buf = temp_esi_buf;
 		goto retry;
 	}
 


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] powerpc/pseries: fix memory leak on krealloc failure in papr_init
  2026-06-14 14:23 [PATCH] powerpc/pseries: fix memory leak on krealloc failure in papr_init Thorsten Blum
@ 2026-07-21  8:15 ` Madhavan Srinivasan
  0 siblings, 0 replies; 2+ messages in thread
From: Madhavan Srinivasan @ 2026-07-21  8:15 UTC (permalink / raw)
  To: Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Kees Cook, Pratik R. Sampat, Thorsten Blum
  Cc: stable, linuxppc-dev, linux-kernel

On Sun, 14 Jun 2026 16:23:56 +0200, Thorsten Blum wrote:
> When krealloc() fails, free the original esi_buf before returning to
> avoid a memory leak.
> 
> 

Applied to powerpc/fixes.

[1/1] powerpc/pseries: fix memory leak on krealloc failure in papr_init
      https://git.kernel.org/powerpc/c/bd83c98b988d2c560531084e296dbfb530aff829

cheers


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-21  8:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-14 14:23 [PATCH] powerpc/pseries: fix memory leak on krealloc failure in papr_init Thorsten Blum
2026-07-21  8:15 ` Madhavan Srinivasan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox