From 159c6ab3aae1212a32c2bd9cd5b9d6309bd0a68d Mon Sep 17 00:00:00 2001 From: Ishwarya Balaji Gururajan Date: Tue, 27 May 2014 16:00:36 -0700 Subject: pstore: fix memleak in ramoops_pstore_read check for size + ecc_notice_size before kmalloc in ramoops_pstore_read to avoid a memleak Bug 200007988 Change-Id: I0e50dcaa229fed29cbd9e8da6d4fb60ce771a7f8 Signed-off-by: Ishwarya Balaji Gururajan Reviewed-on: http://git-master/r/415450 Reviewed-by: Thomas Cherry Reviewed-by: Allen Yu --- fs/pstore/ram.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'fs') diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 1376e5a8f0d6..2a2b21224bc4 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -161,6 +161,9 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type, /* ECC correction notice */ ecc_notice_size = persistent_ram_ecc_string(prz, NULL, 0); + if (!(size + ecc_notice_size)) + return 0; + *buf = kmalloc(size + ecc_notice_size + 1, GFP_KERNEL); if (*buf == NULL) return -ENOMEM; -- cgit v1.2.3