Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d0fecc5 authored by Pan Xinhui's avatar Pan Xinhui Committed by Michael Ellerman
Browse files

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: default avatarPan Xinhui <xinhui.pan@linux.vnet.ibm.com>
Reviewed-by: default avatarNathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 49d09bf2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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)