From patchwork Mon Sep 27 10:02:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 514672 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp3954090jao; Mon, 27 Sep 2021 03:03:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuBnJN2bwdok5/NN+/j7Tp6WzHr8tSfRbfrWjJxbKSXxWzS98zF8vH0GydpzP7OvtGF01+ X-Received: by 2002:a63:5213:: with SMTP id g19mr14884879pgb.87.1632737027128; Mon, 27 Sep 2021 03:03:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632737027; cv=none; d=google.com; s=arc-20160816; b=iniSHrFwBNZa6D82rJ9kwvKKeQLahyZqHpUFJSMFOMEqZmDoTzJ9+tnPLPPLbBxVyx OOYw7p9dY7UTbHxNaYol0F0y6eHD4icWc54i6a8c+egZ54z4TxSjjD/V5vYdbstI0EPJ UbphxyrAu8Sao9QX6lLRjdx47HshCOOrFQaYTA/Z4lEVbZcmYuiANzifxy9t+36+np+a KPbxFOwTv5MpoMtz5lB/kiYvFMyInoEvHaHondxEHISdK0Y1JG4eLbDjD2ygwifsDt/m nmUYIYoPyMKi+MBWBaMn8B9ZzsnHbVcxZgRfJ6iHm0D7MzXtPrsZPI76cUOtc2YbWUIS kQtA== 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=SI7ey/Ptzx81JdLi8Sq5M33GdsycZJnONHg/dsHhM3K68U+N7IskPCKru9aAQuYLEo 2nh225AV6BmfL8QxIudeHKeGckarWG4z8eET8HGZMCJllgRFpIS2RQe2xbNzGHB+JJBU LP8FoHq+9zOjiSkREHCAaDmgYqGL22bMSI2AcQ9xT543RJm6RT1A+GoL1QLp9UeqY54W KEm81JKaKHA8Oh55PFd94prQQc3skcVTBvjec8GoCrefn7iBk/l1uVBsIIr3ULOpO1/l /Re2h1oahQjfwG/AxVgwX4sUiKmQnCJAVsxz3/2z8bEXcT1MlVtFKwb71OGb60h0DWeQ fbaQ== 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 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 q3si19494720pga.299.2021.09.27.03.03.46; Mon, 27 Sep 2021 03:03:47 -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=lRoH0ZoB; 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 S233775AbhI0KFX (ORCPT + 8 others); Mon, 27 Sep 2021 06:05:23 -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 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") 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(+) -- 2.29.2 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;