From patchwork Fri Nov 10 22:10:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 118605 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp8463330qgn; Fri, 10 Nov 2017 14:11:29 -0800 (PST) X-Google-Smtp-Source: AGs4zMb3BEjxs3P1FAUO+vqfd6d8xwc2mKiJ0tKYS7vqeUV+KJ0g7feAJvRNYk4T+/BeC26MXO8a X-Received: by 10.84.230.135 with SMTP id e7mr1701002plk.299.1510351889267; Fri, 10 Nov 2017 14:11:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510351889; cv=none; d=google.com; s=arc-20160816; b=bLmTsI/8BOUVStkEQieOScLwqmsm5WSC2tV+EGTiy8qxrNE4ChU+B4qKK5enVYmfiq JfYdSUXmS3ducFN+bxrdRpcEhYk+EqbtBzzitSI/pRzBT/jHQ2qQmiKdgouABUonrU+w 6A8vJGuDYbYfMlLv4RLhEDHTwZHwF8qTBqA6ECQdkO3SjPnxoOALVPo+6NglCda+Yi8L 2x6A7W9+Dl4VgUCTQEMB6glnOjgzZ7dIWXWth/NTQ+kaF0dHI/l5aJa0k9xtutRCtVGt hx7i+USFx6+JFlaiNSTzyRv+QAeywqFoQte4j301+xTn0uzyD63WoEMz9BUOW75wVtfx 4h3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=b2CI9ch2b0yaGB1/5AdmO/cJclUm6FND/7VAf3Pb9BY=; b=NabQHRWOIJ3MKQgZhcWgW8iOTg/vIoJf5jxGQ0cXtxDIHfXY6vcqRrEpNkoloo9Isu xa4QddzInMlmWhG0IxWhcaknb4AmOZWHdtG77xRND1XKoNGZPn1h6WFjZi0Qt5QuRBz+ fcGyVCKXsbJ1tKSQYn6Bs8t57k7pcLfm+Gcn4vV2fP0ZxhuC0sI73rxlZl/spMgvAYqU OePOJk3qTgw5eOZ5MK+jx1irrIl8CFzclUGzqLnyA0bzyCq2Ts1EXNKnjk0FYJtRnoOT Yq3IiaCGBPA/0TqcdapGlfNGdoklIz+exKe9cQ0h1Iqnyv/5dSo83ovxt//PZQViqOW8 7BwA== 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 m3si9619306pld.479.2017.11.10.14.11.29; Fri, 10 Nov 2017 14:11:29 -0800 (PST) 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 S1754525AbdKJWL2 (ORCPT + 27 others); Fri, 10 Nov 2017 17:11:28 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:58910 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754239AbdKJWL0 (ORCPT ); Fri, 10 Nov 2017 17:11:26 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0MD8Hs-1eRZmN0XNc-00GVus; Fri, 10 Nov 2017 23:11:03 +0100 From: Arnd Bergmann To: Doug Ledford Cc: Christoph Hellwig , Dan Carpenter , Arnd Bergmann , Matan Barak , Yishai Hadas , Sean Hefty , Leon Romanovsky , Dasaratharaman Chandramouli , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] infiniband: avoid uninitialized variable warning in create_udata Date: Fri, 10 Nov 2017 23:10:31 +0100 Message-Id: <20171110221053.3549147-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:4DIMbz3vqliYPlptc4cp3x8/bVm1RqUc1sk6qRow8ILJ8Nu5dLg 7Himt7tH5nJPwtwm2Ahgm0IUV0Zu67ObNJ63L1fCs60FOKHwoDLL2RTyuHWCsCc6Uu4BWjh F0FeRadHRqvYV2jhWkUORa9gMDl/V96c9Poz4NeRpWXmBYEkXQJAReAVjhwV+yTl4cpPNDz IvBO04eiyXKCDTFPdGoVQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:YrffNS55VsI=:UALsbjFUf4DdvG0K4Y2ekl q5uPuP45Cskj7ayc2vEqMumNa6w7GHqmGbprqJJ2amdl6oWkmptedPIhXQMVYAQCO57KC91BA cakcrO/E9V0CbDQWbs53U7Iza5/pLGSd4Wtv30hhbwe1qPU9PufLtZfgDtznOesYvJzt4ihFa AEpMghn4ieHIs/dI2x2PMogrG+Mbc7dLRCz05CMUNvz1DHT4ZQPzWmXRaleLVLYkJCIOLqx5a Mwv8r70kfrlUAcyCeZ1JhRzB1E/tdH46c9OtA2KzZdc34NwXmXz5l1r4Gzfj5ClJ4XaMgLUeP x3m9etmlbeJxs090jujyMkjpJH/udiFvs0FaMZwTRRf2zq3deLjv/evKF9O3SYVlC9X8hXekp LtfELEP9nSNtLdWPe8XBF+MCRFOZdjHKHRv4/zSZB1KLIy/8oj+xnCTjUBQG1NcrZST7T9+vd RFB6yJUK+HbDxn4jDoSHBHC0xJGGMtzuLdZElhPEcYHyDtFoDdt5PEJKQ+mSIatwuooo9P/Rt zzqRc0zLixLnZnJo5HNoqdSdiLg3d5VLJQCY3MogzHbGrJUTkszQu34ozjG/NdprDOalDLYr1 DIH35EYmJbrEN8uI4EZmGjmB1ZrEXbcElm+ePoNeVshJEjab5S06w5ilo503s4lT7hnb4k9Yx zQtaDhAtNpYT8QvPnKnXJ01Dp9wUbANRMQp7A0uMv+NOf0jEOyg3g/4ylOg8rY9+uSsndHyj6 h877mXKetvKvnMwYOAExjwq3yngTr65gZ30/Tw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As Dan pointed out, the rework I did makes it harder for smatch and other static checkers to figure out what is going on with the uninitialized pointers. By open-coding the call in create_udata(), we make it more readable for both humans and tools. Reported-by: Dan Carpenter Fixes: 12f727721eee ("IB/uverbs: clean up INIT_UDATA_BUF_OR_NULL usage") Signed-off-by: Arnd Bergmann --- drivers/infiniband/core/uverbs_std_types.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) -- 2.9.0 Reviewed-by: Leon Romanovsky diff --git a/drivers/infiniband/core/uverbs_std_types.c b/drivers/infiniband/core/uverbs_std_types.c index b095bce7f238..c3ee5d9b336d 100644 --- a/drivers/infiniband/core/uverbs_std_types.c +++ b/drivers/infiniband/core/uverbs_std_types.c @@ -227,27 +227,26 @@ static void create_udata(struct uverbs_attr_bundle *ctx, * to use uverbs_attr_bundle instead of ib_udata. * Assume attr == 0 is input and attr == 1 is output. */ - void __user *inbuf; - size_t inbuf_len = 0; - void __user *outbuf; - size_t outbuf_len = 0; const struct uverbs_attr *uhw_in = uverbs_attr_get(ctx, UVERBS_UHW_IN); const struct uverbs_attr *uhw_out = uverbs_attr_get(ctx, UVERBS_UHW_OUT); if (!IS_ERR(uhw_in)) { - inbuf = uhw_in->ptr_attr.ptr; - inbuf_len = uhw_in->ptr_attr.len; + udata->inbuf = uhw_in->ptr_attr.ptr; + udata->inlen = uhw_in->ptr_attr.len; + } else { + udata->inbuf = NULL; + udata->inlen = 0; } if (!IS_ERR(uhw_out)) { - outbuf = uhw_out->ptr_attr.ptr; - outbuf_len = uhw_out->ptr_attr.len; + udata->outbuf = uhw_out->ptr_attr.ptr; + udata->outlen = uhw_out->ptr_attr.len; + } else { + udata->outbuf = NULL; + udata->outlen = 0; } - - ib_uverbs_init_udata_buf_or_null(udata, inbuf, outbuf, inbuf_len, - outbuf_len); } static int uverbs_create_cq_handler(struct ib_device *ib_dev,