From patchwork Wed Apr 21 13:47:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 425290 Delivered-To: patch@linaro.org Received: by 2002:a17:906:6d12:0:0:0:0 with SMTP id m18csp533219ejr; Wed, 21 Apr 2021 06:48:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqdRQAPmv1o97eg5wmsPWmG9Z0Tyw6xwSA4bNqTgdSeHigCJLzoivpMTdnzA6vo00YGk8d X-Received: by 2002:a17:90a:ce0a:: with SMTP id f10mr10834854pju.98.1619012883358; Wed, 21 Apr 2021 06:48:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619012883; cv=none; d=google.com; s=arc-20160816; b=j4g9ecnp2diJyrv7OAR0/cBf555tVeH3xWjlSswrYT0eAYAdxkTqvEa+4xsJzwPyEY O1DBGXCryXS3cmtofSPGBFpkIri+Zaa4FIgxUN2NoVF8R5NIovLujNETQQ1AJ3g9ffF7 YG9/P2+BcW9e6Jve+NezWZM1UigZccYY6ct6E17hWV2Br2rwqqAaIoxjo3YN4YQoUsHL eDlpw2RdlCF72+uYyo2y8/4Wekt702kzSbHGEC/PEwpcrGt3/NUHytCB5V0N6Hrcmm28 OeZSanoNFA27XdzBOP9GQLhjCPKXFwR2kQ2okf207WWieT/3efKJRhnfgvsOJYJotW3m rLEQ== 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:dkim-signature; bh=4d2m3fXZtxqpXpLKo4+lylVhJ2iyFTdt1g/yDusvcAw=; b=U7KyETrjmH00Qi8sy9n3DW6W2NFbKWeLjxwCWsGmu/dFHo5HYLu7bQMmu04aafmxHA 3lAWvg0ciWcqtKVIPANagjyof6rAOzRnyotMCniSRY8+TyT1c4vR6g+RurMrI7432rxj PRpQJnG4qBemJfAQh4chHgoAjA6rZ74OF7ej12ighuf/n5o/9Bk6Q4tYoQgMLn/ZifxC 7pTYbNZOczG7l93fhYkbTNCqQoUQuMQKnkxH7XoZ+7o6en2zLU7RcEhrp66wk/Ea5gKT VvbPgFo8YIUXAnSXBAlS2ORZhPgC0qHQnQZ/oXbz/34qct7udfOJ8/nQF7TmfTx+SmI2 Z/NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nhD24SoA; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t4si2557237pfd.244.2021.04.21.06.48.03; Wed, 21 Apr 2021 06:48:03 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nhD24SoA; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242780AbhDUNs2 (ORCPT + 8 others); Wed, 21 Apr 2021 09:48:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:56474 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241066AbhDUNs1 (ORCPT ); Wed, 21 Apr 2021 09:48:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4766D60C3E; Wed, 21 Apr 2021 13:47:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619012874; bh=KTVLWVJq8vwl6vTzOgA9P5+hpcqgLU/xnyvuwWytlYE=; h=From:To:Cc:Subject:Date:From; b=nhD24SoAze3qpdTO9xcGGlp+5fd7qGoArYtTzCjyKkgaklPGTEYVGcbeK7XKfXLe2 kn6F8MrroDr8Swusb2ybIXRpbRt/NHdRPbGan00G6hZMRWIQNPSFAriEJPKBqcH2Qw B0oCHNxakFJDXWRTyDUyWxAIsBNCdJDfgxZn8OI9jdfViZut1nlrVp8mEMsMfJVBJ1 0/EA5WUqa+uY/w81+QR+1UU7NoPdCuO8usoXdsfuM3p06iarE+2yea+DSspBrd4yVe bcOFUMbnA08QNPYapoPBNBoZfgthhIhR4BXWQlEcbFnyZiSPqYr5fPWaaqcIV+59db /yIHpNdhKPECg== From: Arnd Bergmann To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski Cc: Arnd Bergmann , Maxime Coquelin , Ong Boon Leong , Voon Weifeng , Joakim Zhang , Fugang Duan , Thierry Reding , "Song, Yoong Siang" , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] [net-next] net: stmmac: fix gcc-10 -Wrestrict warning Date: Wed, 21 Apr 2021 15:47:29 +0200 Message-Id: <20210421134743.3260921-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Arnd Bergmann gcc-10 and later warn about a theoretical array overrun when accessing priv->int_name_rx_irq[i] with an out of bounds value of 'i': drivers/net/ethernet/stmicro/stmmac/stmmac_main.c: In function 'stmmac_request_irq_multi_msi': drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:3528:17: error: 'snprintf' argument 4 may overlap destination object 'dev' [-Werror=restrict] 3528 | snprintf(int_name, int_name_len, "%s:%s-%d", dev->name, "tx", i); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:3404:60: note: destination object referenced by 'restrict'-qualified argument 1 was declared here 3404 | static int stmmac_request_irq_multi_msi(struct net_device *dev) | ~~~~~~~~~~~~~~~~~~~^~~ The warning is a bit strange since it's not actually about the array bounds but rather about possible string operations with overlapping arguments, but it's not technically wrong. Avoid the warning by adding an extra bounds check. Fixes: 8532f613bc78 ("net: stmmac: introduce MSI Interrupt routines for mac, safety, RX & TX") Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.29.2 Reported-by: kernel test robot Reported-by: Dan Carpenter diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index d1ca07c846e6..aadac783687b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3498,6 +3498,8 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev) /* Request Rx MSI irq */ for (i = 0; i < priv->plat->rx_queues_to_use; i++) { + if (i > MTL_MAX_RX_QUEUES) + break; if (priv->rx_irq[i] == 0) continue; @@ -3521,6 +3523,8 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev) /* Request Tx MSI irq */ for (i = 0; i < priv->plat->tx_queues_to_use; i++) { + if (i > MTL_MAX_TX_QUEUES) + break; if (priv->tx_irq[i] == 0) continue;