diff options
author | Ishwarya Balaji Gururajan <igururajan@nvidia.com> | 2014-05-27 16:00:36 -0700 |
---|---|---|
committer | Mandar Padmawar <mpadmawar@nvidia.com> | 2014-05-29 01:49:42 -0700 |
commit | 159c6ab3aae1212a32c2bd9cd5b9d6309bd0a68d (patch) | |
tree | ae294ff05feec26799265d1a0c59370dfd0dc19e /fs/pstore | |
parent | 392b7dbbf3d76f2db05eea05bcf8e1bd9610220b (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/pstore')
-rw-r--r-- | fs/pstore/ram.c | 3 |
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; |