* [PATCH net] net: mvpp2: Don't re-use loop iterator
@ 2024-07-24 16:06 Dan Carpenter
2024-07-24 18:50 ` Simon Horman
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2024-07-24 16:06 UTC (permalink / raw)
To: Stefan Chulski
Cc: Marcin Wojtas, Russell King, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev, linux-kernel,
kernel-janitors
This function has a nested loop. The problem is that both the inside
and outside loop use the same variable as an iterator. I found this
via static analysis so I'm not sure the impact. It could be that it
loops forever or, more likely, the loop exits early.
Fixes: 3a616b92a9d1 ("net: mvpp2: Add TX flow control support for jumbo frames")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 8c45ad983abc..0d62a33afa80 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -953,13 +953,13 @@ static void mvpp2_bm_pool_update_fc(struct mvpp2_port *port,
static void mvpp2_bm_pool_update_priv_fc(struct mvpp2 *priv, bool en)
{
struct mvpp2_port *port;
- int i;
+ int i, j;
for (i = 0; i < priv->port_count; i++) {
port = priv->port_list[i];
if (port->priv->percpu_pools) {
- for (i = 0; i < port->nrxqs; i++)
- mvpp2_bm_pool_update_fc(port, &port->priv->bm_pools[i],
+ for (j = 0; j < port->nrxqs; j++)
+ mvpp2_bm_pool_update_fc(port, &port->priv->bm_pools[j],
port->tx_fc & en);
} else {
mvpp2_bm_pool_update_fc(port, port->pool_long, port->tx_fc & en);
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: mvpp2: Don't re-use loop iterator
2024-07-24 16:06 [PATCH net] net: mvpp2: Don't re-use loop iterator Dan Carpenter
@ 2024-07-24 18:50 ` Simon Horman
2024-07-25 15:04 ` Jakub Kicinski
2024-07-30 16:20 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2024-07-24 18:50 UTC (permalink / raw)
To: Dan Carpenter
Cc: Stefan Chulski, Marcin Wojtas, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel,
kernel-janitors
On Wed, Jul 24, 2024 at 11:06:56AM -0500, Dan Carpenter wrote:
> This function has a nested loop. The problem is that both the inside
> and outside loop use the same variable as an iterator. I found this
> via static analysis so I'm not sure the impact. It could be that it
> loops forever or, more likely, the loop exits early.
>
> Fixes: 3a616b92a9d1 ("net: mvpp2: Add TX flow control support for jumbo frames")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: mvpp2: Don't re-use loop iterator
2024-07-24 16:06 [PATCH net] net: mvpp2: Don't re-use loop iterator Dan Carpenter
2024-07-24 18:50 ` Simon Horman
@ 2024-07-25 15:04 ` Jakub Kicinski
2024-07-30 16:20 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2024-07-25 15:04 UTC (permalink / raw)
To: Dan Carpenter
Cc: Stefan Chulski, Marcin Wojtas, Russell King, David S. Miller,
Eric Dumazet, Paolo Abeni, netdev, linux-kernel, kernel-janitors
On Wed, 24 Jul 2024 11:06:56 -0500 Dan Carpenter wrote:
> This function has a nested loop. The problem is that both the inside
> and outside loop use the same variable as an iterator. I found this
> via static analysis so I'm not sure the impact. It could be that it
> loops forever or, more likely, the loop exits early.
> diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> index 8c45ad983abc..0d62a33afa80 100644
> --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> @@ -953,13 +953,13 @@ static void mvpp2_bm_pool_update_fc(struct mvpp2_port *port,
> static void mvpp2_bm_pool_update_priv_fc(struct mvpp2 *priv, bool en)
> {
> struct mvpp2_port *port;
> - int i;
> + int i, j;
>
> for (i = 0; i < priv->port_count; i++) {
> port = priv->port_list[i];
> if (port->priv->percpu_pools) {
> - for (i = 0; i < port->nrxqs; i++)
> - mvpp2_bm_pool_update_fc(port, &port->priv->bm_pools[i],
> + for (j = 0; j < port->nrxqs; j++)
> + mvpp2_bm_pool_update_fc(port, &port->priv->bm_pools[j],
> port->tx_fc & en);
> } else {
> mvpp2_bm_pool_update_fc(port, port->pool_long, port->tx_fc & en);
Stefan, can you comment? priv->bm_pools are global (not per port)
AFAICT, so this may be semi-intentional.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: mvpp2: Don't re-use loop iterator
2024-07-24 16:06 [PATCH net] net: mvpp2: Don't re-use loop iterator Dan Carpenter
2024-07-24 18:50 ` Simon Horman
2024-07-25 15:04 ` Jakub Kicinski
@ 2024-07-30 16:20 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-07-30 16:20 UTC (permalink / raw)
To: Dan Carpenter
Cc: stefanc, marcin.s.wojtas, linux, davem, edumazet, kuba, pabeni,
netdev, linux-kernel, kernel-janitors
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 24 Jul 2024 11:06:56 -0500 you wrote:
> This function has a nested loop. The problem is that both the inside
> and outside loop use the same variable as an iterator. I found this
> via static analysis so I'm not sure the impact. It could be that it
> loops forever or, more likely, the loop exits early.
>
> Fixes: 3a616b92a9d1 ("net: mvpp2: Add TX flow control support for jumbo frames")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
>
> [...]
Here is the summary with links:
- [net] net: mvpp2: Don't re-use loop iterator
https://git.kernel.org/netdev/net/c/0aa3ca956c46
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] 4+ messages in thread
end of thread, other threads:[~2024-07-30 16:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-24 16:06 [PATCH net] net: mvpp2: Don't re-use loop iterator Dan Carpenter
2024-07-24 18:50 ` Simon Horman
2024-07-25 15:04 ` Jakub Kicinski
2024-07-30 16: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).