From patchwork Mon Dec 11 11:45:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10104837 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4988560650 for ; Mon, 11 Dec 2017 11:46:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF94029555 for ; Mon, 11 Dec 2017 11:46:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E452629557; Mon, 11 Dec 2017 11:46:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DADB29555 for ; Mon, 11 Dec 2017 11:46:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752836AbdLKLqW (ORCPT ); Mon, 11 Dec 2017 06:46:22 -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 Received: from wuerfel.lan ([149.172.96.106]) by mrelayeu.kundenserver.de (mreue004 [212.227.15.129]) with ESMTPA (Nemesis) id 0MNhFO-1eQ1Dc4C4I-007BsN; Mon, 11 Dec 2017 12:46:03 +0100 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-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);