diff mbox

[1/2] powerpc/nvram: Add missing kfree in error path

Message ID 4fd8daff1bb5daad99d909aa75ff5c2702c4c490.1437117145.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State Accepted
Delegated to: Michael Ellerman
Headers show

Commit Message

Christophe JAILLET July 17, 2015, 7:19 a.m. UTC
If 'nvram_write_header' fails, then 'new_part' should be freed, otherwise,
there is a memory leak.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This patch is *untested* because I have no way to trigger the error.
---
 arch/powerpc/kernel/nvram_64.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Michael Ellerman Oct. 12, 2015, 11:17 a.m. UTC | #1
On Fri, 2015-17-07 at 07:19:59 UTC, Christophe Jaillet wrote:
> If 'nvram_write_header' fails, then 'new_part' should be freed, otherwise,
> there is a memory leak.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/7d523187173294f6ae3b86a4

cheers
diff mbox

Patch

diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index 1e703f8..574ff59 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -1079,6 +1079,7 @@  loff_t __init nvram_create_partition(const char *name, int sig,
 	if (rc <= 0) {
 		pr_err("nvram_create_os_partition: nvram_write_header "
 		       "failed (%d)\n", rc);
+		kfree(new_part);
 		return rc;
 	}
 	list_add_tail(&new_part->partition, &free_part->partition);