Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp749701imm; Thu, 13 Sep 2018 07:12:42 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZtNrtZWoBM3jwwdJN5nJsA94LmkP3Dd/yUQPM398M0df7QiFxSwzQSNQ2LP5RrK4b/aiTx X-Received: by 2002:a63:586:: with SMTP id 128-v6mr7407890pgf.169.1536847962904; Thu, 13 Sep 2018 07:12:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536847962; cv=none; d=google.com; s=arc-20160816; b=MeIeTIQKrkWdMrKFa5OZm8yQoVl9hZuTLPwHQetGMkwC03QNCEPW4vjKEL6QOtC/DI gmNGZ3KAN+usPFKJZK/a7REZIc16oMcI/CtqOREeYXHdfJspEvlFEbTqOMcU50l9XER5 XjW0l2YSwtuaJdMK5JNsQVrH6rLQP0aD7vL11JAcgNKUs7Kd+0zNMCLt+C1JpWBG2N3V aDpeJwn3ZKfSH5O9jgy6iidcspodLaQUgG9AB58GG1P+mAnJ+WgpR2Pojyqp9L+eSkuQ EQn/jpQMeX4MobKtHOYKnVMWic4iklec4spKapGylykaCaMqI1UOMOlJ5etvjSAYNdPK xXwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=XOgcO6mBn1jiAi0Ex1ECqXA+TeFJik2cY4nC4ifTTyQ=; b=jttnk3tkubBEr5CCv+ju0qdWy4+MyPYmzM8Xhs/v8zsKRcIsFqFjIfjxQ8iYw59lfC rwQ2TTq99lvdUx8ukbARC6x+Fk7hZJYg1f9mFjCEiN/YV0ze87uh6jI/yPnjUaq4g82s 6jOq9z7Wp3xQSjzKfylR/NDuL7/Odyt2w2PLrLNV1Kblj0YeGlJ/heauCJmHpCdcoSJj +525cIHv+1gqgOCU7lZJ6Mk+rAXvccZ79WVxi4jm6ybo+mDYt+u+TmIZBBYbV8TwxtRX AJhLKmOW4RD6oZgrnbLZL7Z0YYoU4uHrK7eauroLSWwHT1e0Cb1TWLxbm1pMXidpwyyu t/pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="b/fVXnoX"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z73-v6si4079796pgd.471.2018.09.13.07.12.23; Thu, 13 Sep 2018 07:12:42 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="b/fVXnoX"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728427AbeIMTWA (ORCPT + 99 others); Thu, 13 Sep 2018 15:22:00 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:46670 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727844AbeIMTWA (ORCPT ); Thu, 13 Sep 2018 15:22:00 -0400 Received: by mail-lf1-f66.google.com with SMTP id e23-v6so4912872lfc.13; Thu, 13 Sep 2018 07:12:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XOgcO6mBn1jiAi0Ex1ECqXA+TeFJik2cY4nC4ifTTyQ=; b=b/fVXnoXRam31htcGgTY+/CGn2uN2AKJ4RQE9kPFPMFXXkuJKdjaG7EwgB1MH7l2Y3 3yESH8WP8X15t3pIQc8LjnVvMLhzvM8JuQS0ZuYP2ymfndqWKs5gKjQ9L29FZRPgCIBw OGbUU2KHt9UpEUIPIOrtW4JwVqBI9nowTMDMqY7k0iZm9oIQo0CmOVnTYBqYmb/IfeB3 FYPohaa29BwKAon96SCysFV9tdGlEDz/5fP8k92/EWtrgIu7DJYvzZ6HkOo4jwkuAj0E 0N9ryg9sdnj99WGWr0nl1ORfojMTl0/4HJspilrdkFoQXzAKQ+wEhOThP5ZbR9NNguBM ShQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XOgcO6mBn1jiAi0Ex1ECqXA+TeFJik2cY4nC4ifTTyQ=; b=JKQ4ROCjYLsKKhzx7ofZ6amOXlLSh4r0PXx1AtU0tLQG2GUmGSEdbjt8fmCKhOYmwX xLwg7lY+rRynazBvBbtJTJAqvnBZnSmS07F4omD7kQrEqikxm/d2G9NWVwkZlJx13FlD qxNjn4W5ON8r27cb47S4xh1axR0RWamsTj5T1HnEvn4IZp8HjST6oS9dR3Sn3CzG5C/Q RaRTeD6qQzQW8JVODD7n9G/vo47jd9pacjp8lpgqR/fySAih1mrrbI6O6FXb4IGqRuqD z6zAdysISzh/071W1LFx1AY12gzQRYVLx4ImZZLjwzpcomZCtIRcRNRAoqFKUhU/iof9 4aaQ== X-Gm-Message-State: APzg51Dxx2YTlNo+3C9+txSU6fX6DgFx/iIVBT5azV6O95OMQg1/4JbK F4MaBYNvoa47LLWxT2Yngs2yQgnDzsO2HHArKH8= X-Received: by 2002:a19:4283:: with SMTP id p125-v6mr5249890lfa.104.1536847936567; Thu, 13 Sep 2018 07:12:16 -0700 (PDT) MIME-Version: 1.0 References: <20180913133704.15739-1-ricardo.ribalda@gmail.com> In-Reply-To: <20180913133704.15739-1-ricardo.ribalda@gmail.com> From: Ricardo Ribalda Delgado Date: Thu, 13 Sep 2018 16:11:59 +0200 Message-ID: Subject: Re: [PATCH] gpiolib: Free the last requested descriptor To: Linus Walleij , linux-gpio@vger.kernel.org, LKML Cc: timur@codeaurora.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Reported-by: Jan Lorenzen On Thu, Sep 13, 2018 at 3:37 PM Ricardo Ribalda Delgado wrote: > > The current code only frees N-1 gpios if an error occurs during > gpiod_set_transitory, gpiod_direction_output or gpiod_direction_input. > Leading to gpios that cannot be used by userspace nor other drivers. > > Cc: Timur Tabi > Cc: stable@vger.kernel.org > Fixes: ab3dbcf78f60f46d ("gpioib: do not free unrequested descriptors) > Signed-off-by: Ricardo Ribalda Delgado > --- > drivers/gpio/gpiolib.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > index e8f8a1999393..a57300c1d649 100644 > --- a/drivers/gpio/gpiolib.c > +++ b/drivers/gpio/gpiolib.c > @@ -571,7 +571,7 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip) > if (ret) > goto out_free_descs; > lh->descs[i] = desc; > - count = i; > + count = i + 1; > > if (lflags & GPIOHANDLE_REQUEST_ACTIVE_LOW) > set_bit(FLAG_ACTIVE_LOW, &desc->flags); > -- > 2.18.0 > -- Ricardo Ribalda