Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: roid@nvidia.com
Cc: linux-rdma@vger.kernel.org
Subject: [bug report] net/mlx5: E-Switch, Protect changing mode while adding rules
Date: Mon, 16 May 2022 10:04:05 +0300	[thread overview]
Message-ID: <YoH3ZVir5UZUgs3R@kili> (raw)

Hello Roi Dayan,

The patch 7dc84de98bab: "net/mlx5: E-Switch, Protect changing mode
while adding rules" from Sep 16, 2020, leads to the following Smatch
static checker warning:

	drivers/net/ethernet/mellanox/mlx5/core/eswitch.c:2000 mlx5_esw_unlock()
	warn: inconsistent returns '&esw->mode_lock'.

drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
    1996 void mlx5_esw_unlock(struct mlx5_eswitch *esw)
    1997 {
    1998         if (!mlx5_esw_allowed(esw))
    1999                 return;

Smatch is complaining because how will the caller know if we dropped
the lock or not.  I thought, "Hm.  I guess the lock function has a
similar check?  Although, how does that work that mlx5_esw_allowed()
means that it doesn't need locking?"

But then when I looked at the lock function, mlx5_esw_try_lock(), and it
does *NOT* have a similar check.  This probably works because it's
checked in different layers and this is just a duplicative (layering
violation) check which is ugly but harmless.

--> 2000         up_write(&esw->mode_lock);
    2001 }

regards,
dan carpenter

             reply	other threads:[~2022-05-16  7:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-16  7:04 Dan Carpenter [this message]
2022-05-24 18:13 ` [bug report] net/mlx5: E-Switch, Protect changing mode while adding rules Leon Romanovsky

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=YoH3ZVir5UZUgs3R@kili \
    --to=dan.carpenter@oracle.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=roid@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