powerpc/nvram: Add missing kfree in error path
authorChristophe Jaillet <christophe.jaillet@wanadoo.fr>
Fri, 17 Jul 2015 07:19:59 +0000 (09:19 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 2 Oct 2015 12:54:55 +0000 (22:54 +1000)
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>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/nvram_64.c

index 98ba106..72858e9 100644 (file)
@@ -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);