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: 10053873 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 10373603FA for ; Fri, 10 Nov 2017 22:11:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 045D32B490 for ; Fri, 10 Nov 2017 22:11:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBF4A2B492; Fri, 10 Nov 2017 22:11:41 +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=ham 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 75EBE2B490 for ; Fri, 10 Nov 2017 22:11:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754362AbdKJWL1 (ORCPT ); Fri, 10 Nov 2017 17:11:27 -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-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Leon Romanovsky --- drivers/infiniband/core/uverbs_std_types.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) 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,