Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2131415pxb; Thu, 11 Feb 2021 05:19:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzbropVLgJjlI/a95tH8PiyoSkSRxJciTKe1CTmfLto8I+H0YSmNYaCaZX/4euCKgHEDIti X-Received: by 2002:a05:6402:35ca:: with SMTP id z10mr8371528edc.186.1613049561989; Thu, 11 Feb 2021 05:19:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613049561; cv=none; d=google.com; s=arc-20160816; b=z6Wog/oeTj/cp3H8rjjyZYnIIwlPoNKzQPY5TvSKIdeRaKLwXTgKVxCaS58o4zb712 iRZFW+C4DwLU0VmNt8ECnD29noLFzNv/km1k3QmmkPjgFJNhUAyyFfmnPFyAa6KD06a9 eWH4v1l7NRoY/ncecmT8shADTDn41uaXQZrGOZBj20D6iDQHx+spWzIMgP3Wnxulv5vC cgeEAH6+axVhH9Y7fO2NA/+72TsDLGVbCZiMCfSgGfPKYXCINF1Cw/n/Jknuq/ioZhRR aoMAoaGFGi3CfOgr8rHmxqyfviuPPs0pPYWoCUB/Aa9zwmdrOl/czkKm/dJjKST0aQFO rqpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=nIurJyYnXooAph7japWF0bvwzDIzi3mVj0piGVE3cOg=; b=VMrBmxESjBGnbeOXygf6zlAcVsSBUL/iH3Xr3glwJwkBjHFmt2lklU8ufocJ2s9mif dDRLEv3WOXW0q2xmivJmpq+dkCjnms6p7Qx7OErHR61ItqpasH5Gl9VyJuXaOfoirdmG mN4YBnJLzLhGx35Y1niaSEOgEOmpB259GBrOG9YVrXEloW8QZmJvCn0WiBn8LSi8zzBq BGiVn9S4BMsaCw43LTUouQgtW6twsHPl8VOh+dCavUTgeXuQnL9SuNADNh6wcAZvfiuq g3PaLLEkzbqSFa3eukbwmTIwII8meVF9DA3qyYin6s4suFEeX1XQO/c/UP1SedIwRR/E EoIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id de28si3528783edb.466.2021.02.11.05.18.58; Thu, 11 Feb 2021 05:19:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231487AbhBKNQA (ORCPT + 99 others); Thu, 11 Feb 2021 08:16:00 -0500 Received: from foss.arm.com ([217.140.110.172]:51588 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231592AbhBKM5R (ORCPT ); Thu, 11 Feb 2021 07:57:17 -0500 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 Cc: Vincenzo Frascino , Catalin Marinas , Will Deacon , Andrey Konovalov , Andrew Morton 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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)); -- 2.30.0