linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>,
	Tom Rix <trix@redhat.com>, Rolf Eike Beer <eb@emlix.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev, patches@lists.linux.dev,
	Nathan Chancellor <nathan@kernel.org>
Subject: [PATCH -next] mm: pagewalk: Restore err initialization in walk_hugetlb_range()
Date: Tue, 23 Aug 2022 08:30:56 -0700	[thread overview]
Message-ID: <20220823153055.2517764-1-nathan@kernel.org> (raw)

Clang warns:

  mm/pagewalk.c:318:12: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
                  else if (ops->pte_hole)
                          ^~~~~~~~~~~~~
  mm/pagewalk.c:321:7: note: uninitialized use occurs here
                  if (err)
                      ^~~
  mm/pagewalk.c:318:8: note: remove the 'if' if its condition is always true
                  else if (ops->pte_hole)
                      ^~~~~~~~~~~~~~~~~~
  mm/pagewalk.c:311:10: note: initialize the variable 'err' to silence this warning
                  int err;
                        ^
                          = 0
  1 error generated.

Restore the initialization of err to zero so that it cannot be used
uninitialized.

Fixes: 9ce1db56225a ("mm: pagewalk: make error checks more obvious")
Link: https://github.com/ClangBuiltLinux/linux/issues/1694
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---

I am sure that SHA is not stable and I expect this to be squashed into
the original change.

 mm/pagewalk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/pagewalk.c b/mm/pagewalk.c
index 54b2a1beeeb3..76e5ccda8c88 100644
--- a/mm/pagewalk.c
+++ b/mm/pagewalk.c
@@ -308,7 +308,7 @@ static int walk_hugetlb_range(unsigned long addr, unsigned long end,
 	const struct mm_walk_ops *ops = walk->ops;
 
 	for (; addr < end; addr = next) {
-		int err;
+		int err = 0;
 		pte_t *pte = huge_pte_offset(walk->mm, addr & hmask, sz);
 
 		next = hugetlb_entry_end(h, addr, end);

base-commit: d711de4adbec4cb0b8769bcae971b13293e6d311
-- 
2.37.2



             reply	other threads:[~2022-08-23 15:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23 15:30 Nathan Chancellor [this message]
2022-08-24  5:16 ` Rolf Eike Beer

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=20220823153055.2517764-1-nathan@kernel.org \
    --to=nathan@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=eb@emlix.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=llvm@lists.linux.dev \
    --cc=ndesaulniers@google.com \
    --cc=patches@lists.linux.dev \
    --cc=trix@redhat.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