summaryrefslogtreecommitdiff
path: root/fs/pstore
diff options
context:
space:
mode:
authorDouglas Anderson <dianders@chromium.org>2017-05-31 01:50:38 +0300
committerKees Cook <keescook@chromium.org>2017-05-31 20:10:09 +0300
commitf6525b96dd9f68efe374e5aef864975e628de991 (patch)
tree24c125fe9c2db7712df9427715c2ec537cc22449 /fs/pstore
parent4a16d1cb245c56e72fd40a28f3cdb394cde4b341 (diff)
downloadlinux-f6525b96dd9f68efe374e5aef864975e628de991.tar.xz
pstore: Fix leaked pstore_record in pstore_get_backend_records()
When the "if (record->size <= 0)" test is true in pstore_get_backend_records() it's pretty clear that nobody holds a reference to the allocated pstore_record, yet we don't free it. Let's free it. Fixes: 2a2b0acf768c ("pstore: Allocate records on heap instead of stack") Signed-off-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Kees Cook <keescook@chromium.org> Cc: stable@vger.kernel.org
Diffstat (limited to 'fs/pstore')
-rw-r--r--fs/pstore/platform.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index b3045530dd4e..4c5cd9368460 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -849,8 +849,10 @@ void pstore_get_backend_records(struct pstore_info *psi,
record->size = psi->read(record);
/* No more records left in backend? */
- if (record->size <= 0)
+ if (record->size <= 0) {
+ kfree(record);
break;
+ }
decompress_record(record);
rc = pstore_mkfile(root, record);