From 87d5e4a8c36cbb698657a83522bcf5802bce02ce Mon Sep 17 00:00:00 2001 From: Huang Yiwei Date: Thu, 10 Dec 2020 15:38:51 +0800 Subject: [PATCH] pstore: Add buffer start check during init The missing check to prz->start can cause crash because it can be any value and used to locate the write position, so add the start check to avoid. Change-Id: If8ed4db8d9dafab656dd5793aed597463fab628d Signed-off-by: Huang Yiwei --- fs/pstore/ram_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c index 784fe2c035db..86a3ae3694d3 100644 --- a/fs/pstore/ram_core.c +++ b/fs/pstore/ram_core.c @@ -507,7 +507,7 @@ static int persistent_ram_post_init(struct persistent_ram_zone *prz, u32 sig, sig ^= PERSISTENT_RAM_SIG; if (prz->buffer->sig == sig) { - if (buffer_size(prz) == 0) { + if (buffer_size(prz) == 0 && buffer_start(prz) == 0) { pr_debug("found existing empty buffer\n"); return 0; }