mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pstore: Fix leaked pstore_record in pstore_get_backend_records()
@ 2017-05-30 22:50 Douglas Anderson
  2017-05-31 16:54 ` Kees Cook
  0 siblings, 1 reply; 2+ messages in thread
From: Douglas Anderson @ 2017-05-30 22:50 UTC (permalink / raw)
  To: keescook; +Cc: Douglas Anderson, anton, ccross, Tony Luck, linux-kernel

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>
---
 fs/pstore/platform.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index d468eec9b8a6..9defe98ff8b1 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -846,8 +846,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);
-- 
2.13.0.219.gdb65acc882-goog

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-31 16:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-30 22:50 [PATCH] pstore: Fix leaked pstore_record in pstore_get_backend_records() Douglas Anderson
2017-05-31 16:54 ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®