From patchwork Mon Oct 2 11:00:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9980699 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 3438660365 for ; Mon, 2 Oct 2017 11:00:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 262EF28991 for ; Mon, 2 Oct 2017 11:00:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A98A289C6; Mon, 2 Oct 2017 11:00:33 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 8865F2896F for ; Mon, 2 Oct 2017 11:00:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751062AbdJBLAa (ORCPT ); Mon, 2 Oct 2017 07:00:30 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:34036 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751031AbdJBLAa (ORCPT ); Mon, 2 Oct 2017 07:00:30 -0400 Received: by mail-oi0-f67.google.com with SMTP id q133so1049671oic.1 for ; Mon, 02 Oct 2017 04:00:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=bd38dsAKK8Io6NgpP50BFIsCdipBExq3av0O4d7CasQ=; b=QryXLHcCV/pDMn/KZTFZHlzVFYni7r1mp/yK7HbcGAj3hClS8WKGYXywxsWzV96ihJ 9YIeZQ7i6Xr+e5VbIsBhihODq3u2fwzbJ2EiynqVPjCIDVgwAZ0ypeStgH897qSRfOFy g+C3hQh+jx3SQxhr5InEMjCZVjxvTYi3GODqOlYtdTQ0cI4T3ssnTanpXCJd2MgY2hlT PkYaq8Hd+mg15EMZ4TXv1+3Iuo88tjh82yBkKRcMbGLNIyMmTVPzmAc7MAyI43Usjb20 QPJdOfVRkisASZWlXRmoJHql54Q2TP1EzbLqxeTjbsfoLw/fxhq1EMPHTureNCokqcsr tpOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=bd38dsAKK8Io6NgpP50BFIsCdipBExq3av0O4d7CasQ=; b=EXTBSmWjw+epAgbludUqy4GLARL1HTkOkFgRQ1RSYI83YV8lp0PY2QIqMPFxppmZNJ G0Soz9EMC04b2u/um3kp/dTRsVQdu11z78ZlaQMzCRGS1y9h8By82T5etdoDw+3Tacax iEisFPAh1f4p8WnXs37xmDUR9n4gsm07rTeo76m/NdxSkDqZeJbPNkcW4BLBN9mRYAHg 6gKdMCrRVxVbjs8SJrKH9733uXzH7n4XpM5jz6XF0HAvAA49jW0T2sHl6D68Jpdnv3SZ bZ3EN6a+dvAS0zwC5srywM/712shNnp0ma3sgaYqcmynRPA7gUHGotSr6ku3MJ5Xu1uF KDnw== X-Gm-Message-State: AMCzsaWvk026NWjkOZ6oYa3styBF/6cgMeuXe1E3RRpDlN9dOKt4Jtno H4sJNModVEc0NCuTY7iv1RqV8A6LLZm6/NrZDDpWsJNZ X-Google-Smtp-Source: AOwi7QDR4zuAMCAuBiBOCoBqQIp8aLg+iorj0XPVbmwi8ELHC91se10IJb6ll3zDmzExS/Xis9pPmplaSpekz/cdhAc= X-Received: by 10.157.16.5 with SMTP id h5mr973609ote.320.1506942029589; Mon, 02 Oct 2017 04:00:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.0.70 with HTTP; Mon, 2 Oct 2017 04:00:29 -0700 (PDT) In-Reply-To: <20171002101309.dpxylk77ud5gsr2i@mwanda> References: <20171002101309.dpxylk77ud5gsr2i@mwanda> From: Arnd Bergmann Date: Mon, 2 Oct 2017 13:00:29 +0200 X-Google-Sender-Auth: 1F4YFPu-MNS1tBhTi46_rjEVTY0 Message-ID: Subject: Re: [bug report] IB/uverbs: clean up INIT_UDATA_BUF_OR_NULL usage To: Dan Carpenter Cc: linux-rdma , Christoph Hellwig 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 On Mon, Oct 2, 2017 at 12:13 PM, Dan Carpenter wrote: > Hello Arnd Bergmann, > > The patch 12f727721eee: "IB/uverbs: clean up INIT_UDATA_BUF_OR_NULL > usage" from Sep 6, 2017, leads to the following static checker > warning: > > drivers/infiniband/core/uverbs_std_types.c:249 create_udata() > error: uninitialized symbol 'inbuf'. > > drivers/infiniband/core/uverbs_std_types.c > 222 static void create_udata(struct uverbs_attr_bundle *ctx, > 223 struct ib_udata *udata) > 224 { > 225 /* > 226 * This is for ease of conversion. The purpose is to convert all drivers > 227 * to use uverbs_attr_bundle instead of ib_udata. > 228 * Assume attr == 0 is input and attr == 1 is output. > 229 */ > 230 void __user *inbuf; > 231 size_t inbuf_len = 0; > 232 void __user *outbuf; > 233 size_t outbuf_len = 0; > 234 const struct uverbs_attr *uhw_in = > 235 uverbs_attr_get(ctx, UVERBS_UHW_IN); > 236 const struct uverbs_attr *uhw_out = > 237 uverbs_attr_get(ctx, UVERBS_UHW_OUT); > 238 > 239 if (!IS_ERR(uhw_in)) { > 240 inbuf = uhw_in->ptr_attr.ptr; > 241 inbuf_len = uhw_in->ptr_attr.len; > 242 } > 243 > 244 if (!IS_ERR(uhw_out)) { > 245 outbuf = uhw_out->ptr_attr.ptr; > 246 outbuf_len = uhw_out->ptr_attr.len; > 247 } > 248 > 249 ib_uverbs_init_udata_buf_or_null(udata, inbuf, outbuf, inbuf_len, > 250 outbuf_len); > > In the original code, this was a macro so smatch understood that we > don't use inbuf and outbuf if they aren't initialized. Now it's a > function and smatch generates a warning if you pass uninitialized > variables to a function. > > It's not a bug, but it's really ugly. I see. Should we maybe open-code the ib_uverbs_init_udata_buf_or_null() call in this function? Arnd --- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/infiniband/core/uverbs_std_types.c b/drivers/infiniband/core/uverbs_std_types.c index b095bce7f238..039802ae7332 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->inbuf_len = uhw_in->ptr_attr.len; + } else { + udata->inbuf = NULL; + udata->inbuf_len = 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->outbuf_len = uhw_out->ptr_attr.len; + } else { + udata->outbuf = NULL; + udata->outbuf_len = 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,