Received: by 10.213.65.68 with SMTP id h4csp472948imn; Fri, 16 Mar 2018 08:49:21 -0700 (PDT) X-Google-Smtp-Source: AG47ELv4j+AY+XW+w98scrIW0TMngZSEyAnF6gekVXFYUWPHbmP/mGbubMjaLEclcgHCJbzFl9C6 X-Received: by 2002:a17:902:9a08:: with SMTP id v8-v6mr2674675plp.252.1521215361288; Fri, 16 Mar 2018 08:49:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521215361; cv=none; d=google.com; s=arc-20160816; b=q6SvPQTgs0hK2+nTXEUi8fcmT4jYayW+6MOIGDUzUSNwuRM2h0L0ge3mgA6jBqK57r Cy6h/Iq6ISAMAiIqTJVO2tdBc1Z1EfZ3fJK85V/6ArvMSYLvTNGYsmjdQ9zp0rK7UVE5 8LVvVaqcbCE3gzEx+DN6sTpKc0j1bGM8WT2LoUmFoUkRJPAtK8+tSBl2OvcEqboLofPn 6YV82QNMDyHPAqaYaFQNTjXQs8VpE6sYthFknajfT8+nl1jKFTr2MHVK1sIE6QpCJdKd V4gwJvJy0tzvgiN8+246R4LxacW6YMhUlbt/ATQshbjFo34bpdGtMgZmiRWVAXN2HHzB hGCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=c2lPHNpoojhHKtPQPLvR6Q9uSmY7A2YgMWzdVVaKdNg=; b=oVuFyEXif2tyqnsxP+qeBaJxoQI5X52yon+kkT1QQ2xCGmZl3qaAb7PqyeJ+W+Zp8k gKc0AjZNGz22iCw/m3jzEspqo2C3JPed+WKAxW101LdOyGyHtyAmJLDNa7e03ucEUSae 9EhMy5vbCgHA6nev7rOh+XA7z72Q+5il/xmJ8weQCWkO9PZJY+IoJeDDGiQF6axnQMkq oAtdevK5xpolzPGweoj8zMafg+MH1u15nhbFGFsmiZkPwNl1ymUjQvKEqbcRbaE9agqg 417O0wgEq/jIyO1UYRvIrkocRyLWC2rQJ5aA0C+ZmApaecHBSTnZlR/eTpffV5zses/Z F+mQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y9si5113303pgp.800.2018.03.16.08.49.06; Fri, 16 Mar 2018 08:49:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934606AbeCPPrb (ORCPT + 99 others); Fri, 16 Mar 2018 11:47:31 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46150 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965258AbeCPPox (ORCPT ); Fri, 16 Mar 2018 11:44:53 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 2836CF29; Fri, 16 Mar 2018 15:44:52 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.15 126/128] IB/mlx5: revisit -Wmaybe-uninitialized warning Date: Fri, 16 Mar 2018 16:24:27 +0100 Message-Id: <20180316152342.717305290@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152336.199007505@linuxfoundation.org> References: <20180316152336.199007505@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arnd Bergmann [ Upstream commit 1b19b95169cd52fe82cd442fec0b279fe25cc838 ] 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 Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/mlx5/mr.c | 3 +++ 1 file changed, 3 insertions(+) --- 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 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);