Received: by 10.213.65.68 with SMTP id h4csp496054imn; Fri, 16 Mar 2018 09:29:56 -0700 (PDT) X-Google-Smtp-Source: AG47ELuNnBrhiUZpdDLKlYFkIZ8XD7KhrcRlgy54GSUsJqAYp7AwQ+eon4IgA3r/ounfC9/sdIek X-Received: by 2002:a17:902:3a3:: with SMTP id d32-v6mr2849018pld.219.1521217796439; Fri, 16 Mar 2018 09:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521217796; cv=none; d=google.com; s=arc-20160816; b=kMd3YAdkBz6ezDVnChYMDe/C2dypQ+1lDo+rXrWT80e1TMWbP9oZE49LMedurE5azR uEfKXH7MbWLQbDbi3spXV98Q4Hb6Eg1q0h0qveOTKbRgwVloTIVRyOAIicYTgimU/X7m j21YMz4uPJtBwRnwAG1xQm8h/ed4wqkRSQ2eNozuhVacetyWwz+/y38+dUHLBGrCI3h+ uBpG3wGl4d1dFTEIr8n3/6aJIlujMqAVDEhzA4ZTp75tr/LKmnDQA9TTS1VirePtWoog P5ZDewy8Bq7SI/Pe6jHVyCE+hRTQQRmUCTrKvbdhcUUEiXy0jT0B12N7xofywA1+n0tw 2yvQ== 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=SJPB9NUFaimNdoOsc4wf+4vODhgP0Q1dYlVorfZh3dY=; b=GxwkeAo4B1NS8AmVxWpFG92fsOF+IEBumyi+sq2oLsKGshRfNx0ZLZor7iHaEvdnkL E6TcspK7P6upHjvc4l72zlwYKnsh6ByA/QCqKg9Cm/taq2ZZXxjZR4Kne7stiEobZxqz 7uS1pCrQfNIXWmIujl6uiLhN9k752x6cJys+CcLKRyKbgNY8VuR7xRK3P5sGvez3rj8O 5Si3O+6rAZtiLGmjYGp4NkqSRBksgVsXJ+fTbYpYdrjqN+qTJJYWZR/WcbbgWj6OlY7P 0ETgo7hfIC7bFFepf/PqJi/ha/8qqMF1htPasrQgp4fkP//pFGx5sjO2sK9SR6ZZjIHm qHNA== 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 p24si4659148pgn.797.2018.03.16.09.29.42; Fri, 16 Mar 2018 09:29:56 -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 S1752378AbeCPQ2D (ORCPT + 99 others); Fri, 16 Mar 2018 12:28:03 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43148 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934210AbeCPPjG (ORCPT ); Fri, 16 Mar 2018 11:39:06 -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 0C875C19; Fri, 16 Mar 2018 15:39:05 +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.14 107/109] IB/mlx5: revisit -Wmaybe-uninitialized warning Date: Fri, 16 Mar 2018 16:24:16 +0100 Message-Id: <20180316152335.655237781@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152329.844663293@linuxfoundation.org> References: <20180316152329.844663293@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.14-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);