From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0A24C433FE for ; Mon, 27 Sep 2021 13:58:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 98E7560F4F for ; Mon, 27 Sep 2021 13:58:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234690AbhI0OAf (ORCPT ); Mon, 27 Sep 2021 10:00:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:46734 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234645AbhI0OAe (ORCPT ); Mon, 27 Sep 2021 10:00:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 123F460F46; Mon, 27 Sep 2021 13:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632751136; bh=rXDXE/lV9ztJuIJrcfo0ufjzJVIQz5WYCaSugqmwOiM=; h=From:To:Cc:Subject:Date:From; b=PaCxMuZ3LY6eODYPf7LnJv+s8p8D6rwG1/Vi8HhO1hlLLeuf7i5Dm66XtPVH8AvT7 sfzu3hEx5RG9H0Jj8vhAU3p6w29JfBzzqEJ4yLyozjOVx+e/QSVuK1aAYFZ8O1y6oT 95StV/QSyno9YrKWm+F6s0nDtrF4+mENue41KReey11spVF+6SVwcd4YX5Na/vodkO gaOS+1DmubBrNYsuyWV4YjpLZq5JTJ2XEMLFe6ZU9O0Y3OGNwaNzRxISEK+rXjPia4 A2aOqKj7rXid6BVkvfghfHDe5BR4KBKv+4ADjRwPDs5Cy1anZo5lvxZAeWDtPOtrU3 BqlmQVW+EBgmw== From: Arnd Bergmann To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Arnd Bergmann Cc: Russell King , Maxime Coquelin , Ong Boon Leong , Joakim Zhang , Voon Weifeng , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: stmmac: fix off-by-one error in sanity check Date: Mon, 27 Sep 2021 15:58:29 +0200 Message-Id: <20210927135849.1595484-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: netdev@vger.kernel.org From: Arnd Bergmann My previous patch had an off-by-one error in the added sanity check, the arrays are MTL_MAX_{RX,TX}_QUEUES long, so if that index is that number, it has overflown. The patch silenced the warning anyway because the strings could no longer overlap with the input, but they could still overlap with other fields. Fixes: 3e0d5699a975 ("net: stmmac: fix gcc-10 -Wrestrict warning") Reported-by: Russell King (Oracle) Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 640c0ffdff3d..fd4c6517125e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3502,7 +3502,7 @@ 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) + if (i >= MTL_MAX_RX_QUEUES) break; if (priv->rx_irq[i] == 0) continue; @@ -3527,7 +3527,7 @@ 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) + if (i >= MTL_MAX_TX_QUEUES) break; if (priv->tx_irq[i] == 0) continue; -- 2.29.2