Received: by 2002:aa6:cad3:0:b0:147:287a:cb84 with SMTP id e19csp791284lky; Mon, 27 Sep 2021 03:05:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcEI3HbS6jpSY4eoGHnRyaqru7jeygWywiwT/kxgLDXuxEzUl+grPzjIEUZJ5lXdjGIK+Q X-Received: by 2002:a17:90a:2f24:: with SMTP id s33mr18460143pjd.132.1632737149164; Mon, 27 Sep 2021 03:05:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632737149; cv=none; d=google.com; s=arc-20160816; b=jxtkhnXSDcM5IEQBLW3NGBBoP0wcxZkY1PEjcgLUr7NTwBOeeFspuheWVZxEkO2OYV slYrW7vp9tS/n1Py/W1qjWuYDGoqnh71FqdTkAeFPupLvt1/pTTmvuRwrbgPtGV5c4PD AwIzfB/jpA2ZN58kUjLrwcTEaQqPvYKnF9gpgtc3tk/0eusBPUokl2VAbLsa3tftUZp7 lOudUHboju3wScYj5as1tUGv+PKLIraN6+63kDSOBKFV5y8YlgpCo0PnpmDCFePxfUL4 D1i9lyV9Bsm8VgFeQEPABFWje9gY+Me7H26D8i+N3VWHuNA57yQ9mSX1QKHAu6Nv22QC 0/1Q== 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=nerTNJwYf5vA/UL+IdXC3eDFtDR2MWSPNxW+8IWUVfU=; b=jYjsgVoqNnx+EP7M1AFmSQu1cjzvjgvkAog5lxC75PEXf2iNXE09FwX04n8ISPGAiq QDMlgzmFkoXh4+GgWzfK8ffeG/cXSpTBBT7tVeAkFpwYxa89NHK2ErgoQZ83a7v7cW9L Ekqkj2az4QcS/ZwkRUjvzbKRp3ByGFg14/Ih5cqvlcRrFPkvmlO44/HS7gQaLdB7sI1R K+evWlaBMRuzDvOLqovaFwSMwK5c38yRRu3IQHIzgv/lkpu0Cji/ozVyEpG3ucNucjrI PbiicNvct3dVNJ0u5BaTW5DuOvRRnMqlP4d9MmpNRtP204DGpFwDl2Y4jWAsCh1qFxWN reUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lRoH0ZoB; 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=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 f22si19475918pgv.464.2021.09.27.03.05.34; Mon, 27 Sep 2021 03:05:49 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lRoH0ZoB; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233768AbhI0KFW (ORCPT + 99 others); Mon, 27 Sep 2021 06:05:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:56918 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233703AbhI0KFV (ORCPT ); Mon, 27 Sep 2021 06:05:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3C5A560F6C; Mon, 27 Sep 2021 10:03:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632737021; bh=rdXEK8Ftq/XptLnhBL3SXrY8D4WMnjNMPHUHRwbRgVY=; h=From:To:Cc:Subject:Date:From; b=lRoH0ZoBzJ+dFVQrfB+JzPVFwMBUuxUbjt9Ws5BWiRAAHSlQIqwV36x2NyaH1uOQr 3VS28YFgaFOugTBeM9bR8I2dXzFhuEBi4KbEfVhzh1U0SpTVRCqqGQQ7xvGoC1z6tA fyDq/m8eohx7JtqGN6G5OnHM52e1ecNsQopFexcqFUULQEsQ/+qxOkDISnB5qN2a4y +iH8uBehRs5HnZ2C+dZlwkQcYwr/k3OzLP84PGKqpKxjze1Mr0VyK0DzWOO7q4cGfv XtmuQCDwBQpGnr/gbD9vy+WoOZ10TlZw4HoE1M3Uc6OOQiupHFMVLYSohLCtHJQHmU givK5WhsYGcbQ== From: Arnd Bergmann To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Voon Weifeng , Ong Boon Leong Cc: Arnd Bergmann , kernel test robot , Dan Carpenter , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] [RESEND] net: stmmac: fix gcc-10 -Wrestrict warning Date: Mon, 27 Sep 2021 12:02:44 +0200 Message-Id: <20210927100336.1334028-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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") Link: https://lore.kernel.org/all/20210421134743.3260921-1-arnd@kernel.org/ Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 553c4403258a..640c0ffdff3d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3502,6 +3502,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; @@ -3525,6 +3527,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; -- 2.29.2