From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752830AbdLKLqV (ORCPT ); Mon, 11 Dec 2017 06:46:21 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:55948 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752407AbdLKLqR (ORCPT ); Mon, 11 Dec 2017 06:46:17 -0500 From: Arnd Bergmann To: Matan Barak , Leon Romanovsky , Doug Ledford , Jason Gunthorpe Cc: Arnd Bergmann , Artemy Kovalyov , Saeed Mahameed , "David S. Miller" , Ilya Lesokhin , Bart Van Assche , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] IB/mlx5: revisit -Wmaybe-uninitialized warning Date: Mon, 11 Dec 2017 12:45:44 +0100 Message-Id: <20171211114600.3636211-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:z4kDIx027iGRZi6YpkBACADBoBzkD9gkI9MpMU0wdwdELGI1m44 tCQtn2pnuFI02gn0bY7/hakQ6oYVLp9PeajI3nOO/EWmSveyQwBLnIzk7LZstnn1YyVY9xw TlK1xRiFEv68P1hXehRiuHWuJG74D6YGhWzrqNsoc4UaxCx3VKPjqtmW97vwTRP8gOZ1IK9 cU7NkE9wc4PZSoeUTqxkw== X-UI-Out-Filterresults: notjunk:1;V01:K0:WTvGHR1csfo=:VgFfmcDsc3JY6z+15nQJwW t/iEwIi0lfHbonIL0bSFJ/UVY/mQEGn/drlSYlRM3HFCMYRNoLUJFL46Ndk+EObB/8pF4Lulr oDxGavUprw1jXqTdOT9A0Pre+FrUnksK/1SWxF2wBFaUMdhC4AXtNOKa7/x0CFi8Vbjq7rthv Xr1gOMxlnws3kwCr1m4rFp08G0YHv30RuIHAD1PYjupKJCyyxhz+bZTT6p/n+N25DIgrddrW0 StTd/mwKXMDuLYHQ3g3H0y5GDUH1BwhhWEiboiD0n6+1jmgy7ZAWWED4yRzTllO7HUxRRJLdt qWAoLG8NHwzPxZ/C8ryOobcZ0WJk/mz9vvUrfoxTki4UrxJG4n2GRu+mCcvrKJyjIqDudlLXC npD2PjozBSJCIY1OuzWw+hYeeUSNx2hhKEKLX9t4JfmZWNX6uSOPHiSG8Vxa/QoVdqwkLxzV0 3N4EQ2Ptrh7nEjFgFXqmk1CHRdvQTwvLwt+sdRtxpn2pc0QyZYeoHnwyWcAHXIIVnnNJCVZLS UQCzZeEeTegDmEIAxzc0JuzFULA0UOuiAhEScFudWvb2N6/8FCoLVYkktXdbbIDVbQgGpYH3D aiC2lW0piwVkfQ6szh6cKdXeCZRl6qdcKOeknLvfJl2iNMtdxZkDigpChzXoaX9VJVdQH5wsI ykxJ7FwX2GcSnhfJfKcGDUbI2bHSlL6lw3lnp7CH1+Ie6YpxoT6+EkUjQk52KjSHBu3FrFRZ/ zW5bf+z2BIAukRNksSWeHILGPrFp6Qr2cSh1KQ== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index ee0ee1f9994b..ad37d8441fa2 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -1206,6 +1206,9 @@ struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, int err; bool use_umr = true; + if (!IS_ENABLED(CONFIG_INFINIBAND_USER_MEM)) + return ERR_PTR(-EINVAL); + mlx5_ib_dbg(dev, "start 0x%llx, virt_addr 0x%llx, length 0x%llx, access_flags 0x%x\n", start, virt_addr, length, access_flags); -- 2.9.0