From: Vincenzo Frascino <vincenzo.frascino@arm.com>
To: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Andrey Konovalov <andreyknvl@google.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] arm64: Fix warning in mte_get_random_tag()
Date: Thu, 11 Feb 2021 12:56:02 +0000 [thread overview]
Message-ID: <20210211125602.44248-1-vincenzo.frascino@arm.com> (raw)
The simplification of mte_get_random_tag() caused the introduction of the
warning below:
In file included from arch/arm64/include/asm/kasan.h:9,
from include/linux/kasan.h:16,
from mm/kasan/common.c:14:
mm/kasan/common.c: In function ‘mte_get_random_tag’:
arch/arm64/include/asm/mte-kasan.h:45:9: warning: ‘addr’ is used
uninitialized [-Wuninitialized]
45 | asm(__MTE_PREAMBLE "irg %0, %0"
|
Fix the warning initializing the address to NULL.
Note: mte_get_random_tag() returns a tag and it never dereferences the address,
hence 'addr' can be safely initialized to NULL.
Fixes: c8f8de4c0887 ("arm64: kasan: simplify and inline MTE functions")
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
This patch is based on linux-next/akpm
arch/arm64/include/asm/mte-kasan.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/mte-kasan.h b/arch/arm64/include/asm/mte-kasan.h
index 3d58489228c0..b2850b750726 100644
--- a/arch/arm64/include/asm/mte-kasan.h
+++ b/arch/arm64/include/asm/mte-kasan.h
@@ -40,7 +40,12 @@ static inline u8 mte_get_mem_tag(void *addr)
/* Generate a random tag. */
static inline u8 mte_get_random_tag(void)
{
- void *addr;
+ /*
+ * mte_get_random_tag() returns a tag and it
+ * never dereferences the address, hence addr
+ * can be safely initialized to NULL.
+ */
+ void *addr = NULL;
asm(__MTE_PREAMBLE "irg %0, %0"
: "+r" (addr));
--
2.30.0
next reply other threads:[~2021-02-11 13:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-11 12:56 Vincenzo Frascino [this message]
2021-02-11 13:35 ` [PATCH] arm64: Fix warning in mte_get_random_tag() Ard Biesheuvel
2021-02-11 15:10 ` Vincenzo Frascino
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=20210211125602.44248-1-vincenzo.frascino@arm.com \
--to=vincenzo.frascino@arm.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@google.com \
--cc=catalin.marinas@arm.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=will@kernel.org \
/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).