diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 3446c99..f891758 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -474,12 +474,14 @@ void pstore_get_records(int quiet)
 			big_buf_sz = (psinfo->bufsize * 100) / 45;
 			big_buf = allocate_buf_for_decompression(big_buf_sz);
 
-			if (big_buf || stream.workspace)
+			if (big_buf && stream.workspace)
 				unzipped_len = pstore_decompress(buf, big_buf,
 							size, big_buf_sz);
 
 			if (unzipped_len > 0) {
+				kfree(buf);
 				buf = big_buf;
+				big_buf = NULL;
 				size = unzipped_len;
 				compressed = false;
 			} else {
@@ -496,6 +498,7 @@ void pstore_get_records(int quiet)
 		buf = NULL;
 		stream.workspace = NULL;
 		big_buf = NULL;
+		unzipped_len = -1;
 		if (rc && (rc != -EEXIST || !quiet))
 			failed++;
 	}
