summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorIshwarya Balaji Gururajan <igururajan@nvidia.com>2014-05-27 16:00:36 -0700
committerMandar Padmawar <mpadmawar@nvidia.com>2014-05-29 01:49:42 -0700
commit159c6ab3aae1212a32c2bd9cd5b9d6309bd0a68d (patch)
treeae294ff05feec26799265d1a0c59370dfd0dc19e /fs
parent392b7dbbf3d76f2db05eea05bcf8e1bd9610220b (diff)
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 <igururajan@nvidia.com> Reviewed-on: http://git-master/r/415450 Reviewed-by: Thomas Cherry <tcherry@nvidia.com> Reviewed-by: Allen Yu <alleny@nvidia.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/pstore/ram.c3
1 files changed, 3 insertions, 0 deletions
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;