From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752204AbdLKXld (ORCPT ); Mon, 11 Dec 2017 18:41:33 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:34511 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750929AbdLKXl2 (ORCPT ); Mon, 11 Dec 2017 18:41:28 -0500 X-Google-Smtp-Source: ACJfBotdUnxMZg7vXyUc5YvNShm4xK38+AunErtOghZgdMzlvmY1BAWH22lQ0Se5UAIvMdxocmboCA== Date: Mon, 11 Dec 2017 16:41:23 -0700 From: Jason Gunthorpe To: Arnd Bergmann Cc: Matan Barak , Leon Romanovsky , Doug Ledford , Artemy Kovalyov , Saeed Mahameed , "David S. Miller" , Ilya Lesokhin , Bart Van Assche , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: IB/mlx5: revisit -Wmaybe-uninitialized warning Message-ID: <20171211234123.GI32020@ziepe.ca> References: <20171211114600.3636211-1-arnd@arndb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171211114600.3636211-1-arnd@arndb.de> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > drivers/infiniband/hw/mlx5/mr.c | 3 +++ > 1 file changed, 3 insertions(+) Appled to for-next, thanks Jason