From patchwork Thu Feb 11 12:56:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vincenzo Frascino X-Patchwork-Id: 12083199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14322C433DB for ; Thu, 11 Feb 2021 12:57:32 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B8B3A64E08 for ; Thu, 11 Feb 2021 12:57:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B8B3A64E08 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=zbaV6Fo5trpG+nGP+RI52tvyxK48U+Isl4dYkvg/Hkg=; b=W0sjbW+D4O+z5cViBqQg1PnOm0 8CDr5DVl0DeMM2AmyHxuV602Oll0KCgd+DJ3kWhwZh8EeV6ANGCQTnqIOraljHssM8BXERN4jOlnr gCe/j90+MbYlAhGZl8Nbu/xvYaVxCJDyzsAcFGR1AjCLfzR3kkmLVTjSoVMudQ/UiAKUF/ucIxgvE GPBk0/x9FrQYA0Lf6qrcJ5+lOUf1IUC2RkI7z5HDl6DM8f5CoOrxYNjBWSloaCtSK7FJDlpRLIqu4 Nu4U5WhpV7H66rvwi6dtaZnvv40xRx6nvqF2aGVQiCm/MA1enCEVKvljFhSnFQGiqkl4+pdOK64tY rnQmLgMQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lABWF-0001rb-6O; Thu, 11 Feb 2021 12:56:27 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lABWD-0001r6-Hd for linux-arm-kernel@lists.infradead.org; Thu, 11 Feb 2021 12:56:26 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 399B5113E; Thu, 11 Feb 2021 04:56:11 -0800 (PST) Received: from e119884-lin.cambridge.arm.com (e119884-lin.cambridge.arm.com [10.1.196.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1D4743F73B; Thu, 11 Feb 2021 04:56:10 -0800 (PST) From: Vincenzo Frascino To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com Subject: [PATCH] arm64: Fix warning in mte_get_random_tag() Date: Thu, 11 Feb 2021 12:56:02 +0000 Message-Id: <20210211125602.44248-1-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210211_075625_731828_D6A3FD07 X-CRM114-Status: GOOD ( 13.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Catalin Marinas , Andrew Morton , Vincenzo Frascino , Will Deacon , Andrey Konovalov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Cc: Will Deacon Cc: Andrey Konovalov Cc: Andrew Morton Signed-off-by: Vincenzo Frascino --- 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));