netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: stmmac: fix off-by-one error in sanity check
@ 2021-09-27 13:58 Arnd Bergmann
  2021-09-28 12:20 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2021-09-27 13:58 UTC (permalink / raw)
  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, linux-arm-kernel, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

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) <linux@armlinux.org.uk>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: stmmac: fix off-by-one error in sanity check
  2021-09-27 13:58 [PATCH] net: stmmac: fix off-by-one error in sanity check Arnd Bergmann
@ 2021-09-28 12:20 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-09-28 12:20 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, davem, kuba, arnd,
	linux, mcoquelin.stm32, boon.leong.ong, qiangqing.zhang,
	weifeng.voon, netdev, linux-arm-kernel, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Mon, 27 Sep 2021 15:58:29 +0200 you wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> 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.
> 
> [...]

Here is the summary with links:
  - net: stmmac: fix off-by-one error in sanity check
    https://git.kernel.org/netdev/net-next/c/d68c2e1d19c5

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-28 12:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27 13:58 [PATCH] net: stmmac: fix off-by-one error in sanity check Arnd Bergmann
2021-09-28 12:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).