netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Jakub Kicinski <kuba@kernel.org>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
	pabeni@redhat.com, saeedm@nvidia.com
Subject: Re: [PATCH net-next] eth: mlx5: avoid iterator use outside of a loop
Date: Sun, 16 Apr 2023 13:17:53 +0300	[thread overview]
Message-ID: <20230416101753.GB15386@unreal> (raw)
In-Reply-To: <20230414180729.198284-1-kuba@kernel.org>

On Fri, Apr 14, 2023 at 11:07:29AM -0700, Jakub Kicinski wrote:
> Fix the following warning about risky iterator use:
> 
> drivers/net/ethernet/mellanox/mlx5/core/eq.c:1010 mlx5_comp_irq_get_affinity_mask() warn: iterator used outside loop: 'eq'
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: saeedm@nvidia.com
> CC: leon@kernel.org
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/eq.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
> index eb41f0abf798..03c0165a8fd5 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
> @@ -1070,10 +1070,11 @@ mlx5_comp_irq_get_affinity_mask(struct mlx5_core_dev *dev, int vector)
>  
>  	list_for_each_entry(eq, &table->comp_eqs_list, list) {
>  		if (i++ == vector)
> -			break;
> +			return mlx5_irq_get_affinity_mask(eq->core.irq);
>  	}
>  
> -	return mlx5_irq_get_affinity_mask(eq->core.irq);
> +	WARN_ON_ONCE(1);
> +	return 0;

I would do it without changing last return, but "return ERR_PTR(0);"
will do the trick too.

Thanks

>  }
>  EXPORT_SYMBOL(mlx5_comp_irq_get_affinity_mask);
>  
> -- 
> 2.39.2
> 

  parent reply	other threads:[~2023-04-16 10:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-14 18:07 [PATCH net-next] eth: mlx5: avoid iterator use outside of a loop Jakub Kicinski
2023-04-15  4:20 ` kernel test robot
2023-04-16 10:17 ` Leon Romanovsky [this message]
2023-04-17 19:44   ` Jakub Kicinski
  -- strict thread matches above, loose matches on Subject: below --
2023-04-20  1:58 Jakub Kicinski
2023-04-20  4:03 ` Saeed Mahameed
2023-04-21  2:50 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230416101753.GB15386@unreal \
    --to=leon@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).