Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1698939pxj; Wed, 19 May 2021 11:46:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxQh4M44pgXIDf+/2ZmBq+dxmVX5cjGQhpYgXI7/x+e4b8522MjdlQnsUp6L/qFqiNZgY/ X-Received: by 2002:aa7:dc49:: with SMTP id g9mr500858edu.160.1621449962535; Wed, 19 May 2021 11:46:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621449962; cv=none; d=google.com; s=arc-20160816; b=k3Y7SERGQoHD6EQ2cW6zsS7JqfMQpVKAPY/u/Pyn4wKByfo6xalsAihhTZr/oJqj0a h8DAAlNSTcJdjS/AylpBjVVVDsY5UmOb6wQ8PJOed2B++ufT0Ygett1z+brpORxdgXjV NvFpcManSXQsKaa186A98JWpmyX8btV2DBn2UDveMOAim7Ktx5slFZQVRhJSQinwCFVh eZ6B/hhUxLiMTc8F7iCpXNAPVVB3IoC4gYcjPp5zkxWSimrCLqYiaDRMYcXpUUNIYbLF 61RTJmfJYlR7MqAtZMDz9rblYaA+TNbFGKfL+Bn/04+wr/hZkd+1bjc2YOuWM6dFL6dv SG9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FTF5xfQUi9rq73u8UhSiFIg3U+v2ywpSRf/wbD9ZbIs=; b=hQAt8euwkib3gCEoXNxI3jstyapP4+xVUUPgEayp9EIpLJQD374pZgAqYslPiuALOS NZ/Vqmq+DTXF0YpHCvxT2QVHJjCW9vFWXLrkHwxaCSOUYb8NPE5GVJP+AbEgehLKD1IO qyoX51KiPGGaJaiXsCf8m9xikCJJhDryw3hG0it1tN8mW99AT1CGJ/Q7Jj1yed5XRn2A IxfdPvUb93Av+4vXG1eXMbflh8MRurl84f1egeSSO3b2PybTiclhGCdd1dfEzojidxXy l8yNqfonQUNRfjKS+DlgOVL+6k7ba4iTxzn/WDv0h1dN9fuaZ71gIhA9l/HUs9k1c6Xk qW5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Kic7eSJy; 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 fx13si334827ejb.602.2021.05.19.11.45.37; Wed, 19 May 2021 11:46:02 -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=Kic7eSJy; 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 S234544AbhERX0S (ORCPT + 99 others); Tue, 18 May 2021 19:26:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230352AbhERX0Q (ORCPT ); Tue, 18 May 2021 19:26:16 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37A4CC061573; Tue, 18 May 2021 16:24:58 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id c17so8578018pfn.6; Tue, 18 May 2021 16:24:58 -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=FTF5xfQUi9rq73u8UhSiFIg3U+v2ywpSRf/wbD9ZbIs=; b=Kic7eSJyxdf5rrMmuTri/4ZD+gAmSKGSaTH6uNqOKCj8oUeYcRMHuHWUDVvb37AzBq 9KprYsGbwHIkvRKo/va/QOpomDqphxZSfX7Y5gzKQzOMzTDH6aqG2vJEGlDLeM7/p0v5 jbiJPrf5SoO7PrDfThUd5sURTPEnzu//9mtTv0MKVbnsMSb6GzUBWVHv41eRrE4XNVx8 /vP0w2PwxzZLpvijs26vP/Ob1PaF38fwxciasZ8w3n9W01iYz75U5woX6wpOPMpV7H7D 53SAeI0AXrbGs+RnhPWvO2R63pjvI/EeZggM85LD4rH8JPuNfrke6rSm9hy9RYhjjEDb bSLg== 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=FTF5xfQUi9rq73u8UhSiFIg3U+v2ywpSRf/wbD9ZbIs=; b=aC+fZ+esRtDIocOti0EwZmx4su2IbsaFfLCIi/xLfmKXypAPh89gITm1naWpoeCnWF 5P72VfjIchDUo/tM+Nc+6uv4C9cc1fUx2NS0REETiowS4QPM1L/gQ7bZcDcGo8ymDhnZ JQygMQrtPe5ZF0/RZRdsHZoAFn+vKDzYezS3qsB63kqDw4lROkEnuIGUfcFMl9xCDiyX c7dl6W/OHgstH6uSlh+fivVs9trRKbdWz8TAgwaUCyqmpENtL/Hl5Iu10k4fSk1KU3Xi t1JrudhREQn1fFdL9siCVxwQKzfpkwmQjs1Uber5gI/El+KyB/S3anWZcsXXuuEGYPLy h+MQ== X-Gm-Message-State: AOAM532p/Tdh4nfWYPp82ej9ClKNDkH7Xlglbg/J22TMh0Eet+Q2oBK0 xEGv/Vgi4lGHghX3ev3jxnk= X-Received: by 2002:a65:6844:: with SMTP id q4mr7535519pgt.224.1621380297618; Tue, 18 May 2021 16:24:57 -0700 (PDT) Received: from sol (106-69-175-91.dyn.iinet.net.au. [106.69.175.91]) by smtp.gmail.com with ESMTPSA id l126sm13859362pga.41.2021.05.18.16.24.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 16:24:56 -0700 (PDT) Date: Wed, 19 May 2021 07:24:51 +0800 From: Kent Gibson To: Andy Shevchenko Cc: Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij , Suresh Balakrishnan Subject: Re: [PATCH v1 1/2] gpiolib: Never return internal error codes to user space Message-ID: <20210518232451.GA7362@sol> References: <20210518155013.45622-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210518155013.45622-1-andriy.shevchenko@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 18, 2021 at 06:50:12PM +0300, Andy Shevchenko wrote: > Currently it's possible that character device interface may return > the error codes which are not supposed to be seen by user space. > In this case it's EPROBE_DEFER. > > Wrap it to return -ENODEV instead as sysfs does. > > Fixes: d7c51b47ac11 ("gpio: userspace ABI for reading/writing GPIO lines") > Fixes: 61f922db7221 ("gpio: userspace ABI for reading GPIO line events") > Fixes: 3c0d9c635ae2 ("gpiolib: cdev: support GPIO_V2_GET_LINE_IOCTL and GPIO_V2_LINE_GET_VALUES_IOCTL") > Reported-by: Suresh Balakrishnan > Signed-off-by: Andy Shevchenko > --- > drivers/gpio/gpiolib-cdev.c | 15 ++++++++++++--- > 1 file changed, 12 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c > index 1631727bf0da..1d8f66880d63 100644 > --- a/drivers/gpio/gpiolib-cdev.c > +++ b/drivers/gpio/gpiolib-cdev.c > @@ -331,8 +331,11 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip) > } > > ret = gpiod_request(desc, lh->label); > - if (ret) > + if (ret) { > + if (ret == -EPROBE_DEFER) > + ret = -ENODEV; > goto out_free_lh; > + } > lh->descs[i] = desc; > linehandle_flags_to_desc_flags(handlereq.flags, &desc->flags); > > @@ -1379,8 +1382,11 @@ static int linereq_create(struct gpio_device *gdev, void __user *ip) > } > > ret = gpiod_request(desc, lr->label); > - if (ret) > + if (ret) { > + if (ret == -EPROBE_DEFER) > + ret = -ENODEV; > goto out_free_linereq; > + } > > lr->lines[i].desc = desc; > flags = gpio_v2_line_config_flags(lc, i); > @@ -1765,8 +1771,11 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip) > } > > ret = gpiod_request(desc, le->label); > - if (ret) > + if (ret) { > + if (ret == -EPROBE_DEFER) > + ret = -ENODEV; > goto out_free_le; > + } > le->desc = desc; > le->eflags = eflags; > You immediately revert this patch in patch 2. My understanding is that is not allowed within a patch set. Why split the patches instead of going direct to the new helper? Cheers, Kent.