From: Leon Romanovsky <leon@kernel.org>
To: Jules Irenge <jbi.octave@gmail.com>
Cc: edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net/mlx5e: Remove NULL check before dev_{put, hold}
Date: Tue, 30 Apr 2024 16:16:03 +0300 [thread overview]
Message-ID: <20240430131603.GF100414@unreal> (raw)
In-Reply-To: <Zi5NUDItYAyDGdwV@octinomon.home>
On Sun, Apr 28, 2024 at 02:21:20PM +0100, Jules Irenge wrote:
> Coccinelle reports a warning
>
> WARNING: NULL check before dev_{put, hold} functions is not needed
>
> The reason is the call netdev_{put, hold} of dev_{put,hold} will check NULL
> There is no need to check before using dev_{put, hold}
>
> Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
> index 8dfb57f712b0..f23d7116e6d8 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
> @@ -68,16 +68,14 @@ static int get_route_and_out_devs(struct mlx5e_priv *priv,
> * while holding rcu read lock. Take the net_device for correctness
> * sake.
> */
> - if (uplink_upper)
> - dev_hold(uplink_upper);
> + dev_hold(uplink_upper);
I see same if (..) dev_hold() in drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c too.
> rcu_read_unlock();
>
> dst_is_lag_dev = (uplink_upper &&
> netif_is_lag_master(uplink_upper) &&
> real_dev == uplink_upper &&
> mlx5_lag_is_sriov(priv->mdev));
> - if (uplink_upper)
> - dev_put(uplink_upper);
> + dev_put(uplink_upper);
This pattern exists in other places in the same file and others too.
Let's change all of them in one patch.
Thanks
>
> /* if the egress device isn't on the same HW e-switch or
> * it's a LAG device, use the uplink
> --
> 2.43.2
>
>
prev parent reply other threads:[~2024-04-30 13:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-28 13:21 [PATCH] net/mlx5e: Remove NULL check before dev_{put, hold} Jules Irenge
2024-04-30 13:16 ` Leon Romanovsky [this message]
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=20240430131603.GF100414@unreal \
--to=leon@kernel.org \
--cc=edumazet@google.com \
--cc=jbi.octave@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=pabeni@redhat.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).