Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp394488pxk; Thu, 3 Sep 2020 02:33:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3nY58Q7guw7AF9gSrfY3hOnEp6W2U9E869lkdEiUpmicKcevHjX/fUUbFITTsw8tfZP1e X-Received: by 2002:a17:906:7688:: with SMTP id o8mr1180358ejm.508.1599125597397; Thu, 03 Sep 2020 02:33:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599125597; cv=none; d=google.com; s=arc-20160816; b=iIJzutCZ4a9kMUIa5R6ICJ1jX01p06tYbJmedV0fFS/QdXo11YLDW0lkYXjEe8L3ME 34rGHXPDh4SJbL9tRZGsWRZIDSbOdlshy+p+yrEiOfWVtRfbvVcDTHDRccHhudK1+4JZ RvP6mOg4eSiStLpAYKJ6zEs9IDQOc3pqHkjuGZyRDI7Uq1GzRdVacBYSdMBWFMIEZQas /VZme9ZtRZ8ZneRL9CxcIrnAzP1Uz6i1BTwlFAulUnMAb81FyHaWbIG8FKXLK0DtZS1N GpTDAbsFqGmMZZIW/E3NToF4riopYu3S8mM9D1hnURiG3Lv3XdJ3iNCCIi3VUngCkr/2 pnNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=+sd9erymWD13Cu188GljsOgb+/pwjw6f4RPyPst8OkY=; b=YDRUCV46/ogRegWHIvSAUxv0bA54KrtFxH6vtHnqF07DulzPP3rrmGCKTMSIa8MQRM 0+Dt/ZfRN9S63rNcQozGtxChOqehXZ8Jvt4ZfpzLMb6sY+mZnkxmMU4/h+nLABsMHt+u E9mj4q8MZKsNz1sta07ujRcA9Adz9IqZDI9TB77XkhVhJEDoFVqTVfqsTNQ3mOji/knI tUkoH/TuUW1EK8kK3E8diILljc/9+26N5jo+EesIUADlZIA3X6PlS2fg72PhF8RvDjJI 1okGjv8IZ2yvc4U1PUs/ZpTwo/9ef2nJgscjv+4pPp5a3V8kcebGXy9HmAX9f7vD1DQo UNhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="J/OxbLk2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p21si1504416eds.193.2020.09.03.02.32.49; Thu, 03 Sep 2020 02:33:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="J/OxbLk2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727989AbgICJb2 (ORCPT + 99 others); Thu, 3 Sep 2020 05:31:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726268AbgICJb0 (ORCPT ); Thu, 3 Sep 2020 05:31:26 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D73BC061244; Thu, 3 Sep 2020 02:31:26 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id u20so1874336pfn.0; Thu, 03 Sep 2020 02:31:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=+sd9erymWD13Cu188GljsOgb+/pwjw6f4RPyPst8OkY=; b=J/OxbLk24+mWs+zAdfKaJvLOQ/2cBymrYF8hpD4EbkzEsMAD5eZQv6+g2I1UcC4tjL OQtWr/BkAtnRpcx2YvcbZcdYMP3Q4vQgJ7Vt9CN8G4h93rqrprc16hutf82PaTl9SPpC MDw7cdmI2V4dV6SD11qKcESfhzmc5Ae4OGqiWqD6wied1AG9KPcTxoLFvZm6jM1jJQA+ qhpcJEvTOjOttnuLxEBKPnEL2KPS9lieYo3PsREIP3SoN2EcS2nH9RrhSwkZNJ6MD6hv hpk9kIIVPwGdrjluOubDR4X7yWL4JNxOGutUSXOfo8mWYlpJzVXShrXGFHRlPygpm8Td E+vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=+sd9erymWD13Cu188GljsOgb+/pwjw6f4RPyPst8OkY=; b=sRii/9jz8v1GQITUS9qtXsUxBXkoBLTOItQt8liKYodf8XdtR1lEeDymGFv1eMh7lH JnJFU1NkXeM6LfWxAVdMHUnDwRnvaa4kdCocWl5u0+U6doA2wEx6Qctl5OfLbLu6jep2 pY620OnKQzityVVqZd5je1B7XbGvx4EYq84mQdhoTZb2BJcdDPeH//X4IsfeJvJ0cP17 bgrgoNu20NRmonhFzk/+ntZeEXMpw2DA6ku/rluAZ3XPvOoHtTq7dm/vSdfL4smbKC17 tdgmBfK/SW/IOy0Yr2NOOnbRftTUPl5r7OjBEIM7jlf3lJNlSONT1Pay+iZmWUKj/nv3 dgkg== X-Gm-Message-State: AOAM530u/Djv34h+D+7Bplx83INfcZ3salDYOinYlhoxxQXZ7xa1CEsR gqbD6kqHbqqBhhO4P2NmbK9kOn1bISo= X-Received: by 2002:a62:7fd1:: with SMTP id a200mr2964557pfd.175.1599125485626; Thu, 03 Sep 2020 02:31:25 -0700 (PDT) Received: from sol (106-69-184-100.dyn.iinet.net.au. [106.69.184.100]) by smtp.gmail.com with ESMTPSA id d1sm1873301pjs.17.2020.09.03.02.31.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 02:31:24 -0700 (PDT) Date: Thu, 3 Sep 2020 17:31:20 +0800 From: Kent Gibson To: Bartosz Golaszewski Cc: LKML , linux-gpio , Linus Walleij Subject: Re: [PATCH v6 11/20] gpiolib: cdev: support GPIO_V2_LINE_SET_VALUES_IOCTL Message-ID: <20200903093120.GA160697@sol> References: <20200831032006.1019978-1-warthog618@gmail.com> <20200831032006.1019978-12-warthog618@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 03, 2020 at 09:59:17AM +0200, Bartosz Golaszewski wrote: > On Mon, Aug 31, 2020 at 5:23 AM Kent Gibson wrote: > > > > Add support for the GPIO_V2_LINE_SET_VALUES_IOCTL. > > > > Signed-off-by: Kent Gibson > > --- > > drivers/gpio/gpiolib-cdev.c | 59 +++++++++++++++++++++++++++++++++++++ > > 1 file changed, 59 insertions(+) > > > > diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c > > index 936b8c9958dd..9f05bbd2161e 100644 > > --- a/drivers/gpio/gpiolib-cdev.c > > +++ b/drivers/gpio/gpiolib-cdev.c > > @@ -777,6 +777,63 @@ static long linereq_get_values(struct linereq *lr, void __user *ip) > > return 0; > > } > > > > +static long linereq_set_values_unlocked(struct linereq *lr, > > + struct gpio_v2_line_values *lv) > > +{ > > + DECLARE_BITMAP(vals, GPIO_V2_LINES_MAX); > > + struct gpio_desc **descs; > > + unsigned int i, didx, num_set; > > + int ret; > > + > > + bitmap_zero(vals, GPIO_V2_LINES_MAX); > > + for (num_set = 0, i = 0; i < lr->num_lines; i++) { > > + if (lv->mask & BIT_ULL(i)) { > > + if (!test_bit(FLAG_IS_OUT, &lr->lines[i].desc->flags)) > > + return -EPERM; > > + if (lv->bits & BIT_ULL(i)) > > + __set_bit(num_set, vals); > > + num_set++; > > + descs = &lr->lines[i].desc; > > + } > > + } > > + if (num_set == 0) > > + return -EINVAL; > > + > > + if (num_set != 1) { > > + /* build compacted desc array and values */ > > + descs = kmalloc_array(num_set, sizeof(*descs), GFP_KERNEL); > > Missing retval check. > Arrgh, that has been there since PATCH v2! And subsequently got propagated into patch 07 :-(. Kent.