forked from Minki/linux
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>
This commit is contained in:
parent
49d09bf2a6
commit
0d0fecc5b5
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user