public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Matan Barak <matanb@mellanox.com>,
	Leon Romanovsky <leonro@mellanox.com>,
	Doug Ledford <dledford@redhat.com>,
	Artemy Kovalyov <artemyko@mellanox.com>,
	Saeed Mahameed <saeedm@mellanox.com>,
	"David S. Miller" <davem@davemloft.net>,
	Ilya Lesokhin <ilyal@mellanox.com>,
	Bart Van Assche <bart.vanassche@sandisk.com>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: IB/mlx5: revisit -Wmaybe-uninitialized warning
Date: Mon, 11 Dec 2017 16:41:23 -0700	[thread overview]
Message-ID: <20171211234123.GI32020@ziepe.ca> (raw)
In-Reply-To: <20171211114600.3636211-1-arnd@arndb.de>

On Mon, Dec 11, 2017 at 12:45:44PM +0100, Arnd Bergmann wrote:
> A warning that I thought I had fixed before occasionally comes
> back in rare randconfig builds (I found 7 instances in the last
> 100000 builds, originally it was much more frequent):
> 
> drivers/infiniband/hw/mlx5/mr.c: In function 'mlx5_ib_reg_user_mr':
> drivers/infiniband/hw/mlx5/mr.c:1229:5: error: 'order' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>   if (order <= mr_cache_max_order(dev)) {
>      ^
> drivers/infiniband/hw/mlx5/mr.c:1247:8: error: 'ncont' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/infiniband/hw/mlx5/mr.c:1247:8: error: 'page_shift' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/infiniband/hw/mlx5/mr.c:1260:2: error: 'npages' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> I've looked at all those findings again and noticed that they are all
> with CONFIG_INFINIBAND_USER_MEM=n, which means ib_umem_get() returns
> an error unconditionally and we never initialize or use those variables.
> This triggers a condition in gcc iff mr_umem_get() is partially but not
> entirely inlined, which in turn depends on the exact combination of
> optimization settings. This is a known problem with gcc, with no
> easy solution in the compiler, so this adds another workaround that
> should be more reliable than my previous attempt.
> 
> Returning an error from mlx5_ib_reg_user_mr() earlier means that we
> can completely bypass the logic that caused the warning, the compiler
> can now see that the variable is never accessed.
> 
> Fixes: 14ab8896f5d9 ("IB/mlx5: avoid bogus -Wmaybe-uninitialized warning")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>  drivers/infiniband/hw/mlx5/mr.c | 3 +++
>  1 file changed, 3 insertions(+)

Appled to for-next, thanks

Jason

      reply	other threads:[~2017-12-11 23:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-11 11:45 [PATCH] IB/mlx5: revisit -Wmaybe-uninitialized warning Arnd Bergmann
2017-12-11 23:41 ` Jason Gunthorpe [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=20171211234123.GI32020@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=arnd@arndb.de \
    --cc=artemyko@mellanox.com \
    --cc=bart.vanassche@sandisk.com \
    --cc=davem@davemloft.net \
    --cc=dledford@redhat.com \
    --cc=ilyal@mellanox.com \
    --cc=leonro@mellanox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=matanb@mellanox.com \
    --cc=saeedm@mellanox.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