linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Joel Fernandes (Google)" <joel@joelfernandes.org>
To: linux-kernel@vger.kernel.org
Cc: "Joel Fernandes (Google)" <joel@joelfernandes.org>,
	Anton Vorontsov <anton@enomsg.org>,
	Colin Cross <ccross@android.com>,
	Kees Cook <keescook@chromium.org>,
	Tony Luck <tony.luck@intel.com>
Subject: [PATCH RFC v2 3/3] pstore: donot treat empty buffers as valid
Date: Sat,  3 Nov 2018 16:38:18 -0700	[thread overview]
Message-ID: <20181103233818.44615-4-joel@joelfernandes.org> (raw)
In-Reply-To: <20181103233818.44615-1-joel@joelfernandes.org>

pstore currently calls persistent_ram_save_old even if a buffer is
empty. While this appears to work, it is does not seem like the right
thing to do and could lead to future bugs so lets avoid that. It also
prevent misleading prints in the logs which claim the buffer is valid.

I got something like:
found existing buffer, size 0, start 0

When I was expecting:
no valid data in buffer (sig = ...)

Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
---
Note that if you feel this patch is not necessary, then feel free to
drop it. I would say it is harmless and is a good clean up.

 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 e6375439c5ac..196e4fd7ba8c 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -510,7 +510,7 @@ static int persistent_ram_post_init(struct persistent_ram_zone *prz, u32 sig,
 
 	sig ^= PERSISTENT_RAM_SIG;
 
-	if (prz->buffer->sig == sig) {
+	if (prz->buffer->sig == sig && buffer_size(prz)) {
 		if (buffer_size(prz) > prz->buffer_size ||
 		    buffer_start(prz) > buffer_size(prz)) {
 			pr_info("found existing invalid buffer, size %zu, start %zu\n",
-- 
2.19.1.930.g4563a0d9d0-goog

  parent reply	other threads:[~2018-11-03 23:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-03 23:38 [PATCH RFC v2 0/3] cleanups for pstore and ramoops Joel Fernandes (Google)
2018-11-03 23:38 ` [PATCH RFC v2 1/3] pstore: map pstore types to names Joel Fernandes (Google)
2018-11-05  4:46   ` Joel Fernandes
2018-11-03 23:38 ` [PATCH RFC v2 2/3] pstore: simplify ramoops_get_next_prz arguments Joel Fernandes (Google)
2018-11-03 23:38 ` Joel Fernandes (Google) [this message]
2018-11-14  7:14 ` [PATCH RFC v2 0/3] cleanups for pstore and ramoops Kees Cook
2018-11-15  2:20   ` Joel Fernandes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181103233818.44615-4-joel@joelfernandes.org \
    --to=joel@joelfernandes.org \
    --cc=anton@enomsg.org \
    --cc=ccross@android.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).