diff options
author | Pan Xinhui <xinhui.pan@linux.vnet.ibm.com> | 2015-12-09 18:00:53 +0800 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2016-09-20 16:15:33 +1000 |
commit | 0d0fecc5b5bfddb0e67bef985cdeda2eac7ad6d8 (patch) | |
tree | f0cde1a3c27e0f6b43e22e2e86135d50655fff6c /arch | |
parent | 49d09bf2a66f4b5a6eabefb0d4c0f03f21810553 (diff) |
powerpc/nvram: Fix a memory leak in err path
If kmemdup fails, We need kfree *buff* first then return -ENOMEM.
Otherwise there is a memory leak.
Signed-off-by: Pan Xinhui <xinhui.pan@linux.vnet.ibm.com>
Reviewed-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/kernel/nvram_64.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c index 46c3c76f171b..6cd3a45880c0 100644 --- a/arch/powerpc/kernel/nvram_64.c +++ b/arch/powerpc/kernel/nvram_64.c @@ -542,9 +542,9 @@ static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type, time->tv_nsec = 0; } *buf = kmemdup(buff + hdr_size, length, GFP_KERNEL); + kfree(buff); if (*buf == NULL) return -ENOMEM; - kfree(buff); *ecc_notice_size = 0; if (err_type == ERR_TYPE_KERNEL_PANIC_GZ) |