Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp709336imm; Thu, 13 Sep 2018 06:38:48 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbMw77oBxeNKHtkLpEffK29V5h4xh2LVES1/jb/NGPFStFjw1KAtiBmwoRSZLECUgDo2tNv X-Received: by 2002:a17:902:59cf:: with SMTP id d15-v6mr7522601plj.184.1536845928249; Thu, 13 Sep 2018 06:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536845928; cv=none; d=google.com; s=arc-20160816; b=09OWDgdjiumiWgY9o5WUfZIxPxLWinF+AiLjkP3K1X+2P/kaMeEAU0T1XQG09kHBx1 JrOQfuCrsT8uEVljkXXqfwVW85o5w8gyjDCttW49C7jP7S3m7R+njgHePInDoAvWtv8p sgmzZE33TeMQTDGMn88wI2aZ45nvPNb6SQL7w7F8UhCs7xF6TVBGIwJXCevTWcU1en+0 42+ixyXh12wm88M0LEqinjy3emMmizHWeFT4o4cAP0KtGLDzl0vqRX49cz6ptBzMVnjF U/9VLmpTne0s4kotC66cs2PiyshovIESLhbeJMUq1I3jjN5KVVQDMmSiMn9jIsq05dNU Ja7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=ZUDSm2FD2hYYPP2BfK4f9rXkC1bUeU5Jp9/jFHeXBjE=; b=cnFPJ/m4kIlTssOcTyRGN+CBjIHM013H3OAYwlEpVJnZ90R/czKWCCNCTFW9cbp3wa L/sTPK3CRV8l/vfgpQd8/zrm3TvW1r93fwek5QoZDxSMhx9EuSx6IkKOwmz06duCXKov fidvovQ1gVxamCBGDSAp60gdPaoS1NDRgmJ33ciOdHpYYruTFqx7KmWUdR6BqUSv4As5 jZgXXBZXyR5ulcXrqf6sZDSMRmv6dhu3HFj0awu820qbYbr0DtiusmZVfEtDE26Y3MjQ sf8pVXr2Mp1Iw42S5rsy4MWuuXxn2ikbXEj4GBJKNLMz7QtcameJnfK4owxy3uOxGo9l mzng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cRFk6fxe; 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 w61-v6si4071456plb.511.2018.09.13.06.38.32; Thu, 13 Sep 2018 06:38:48 -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=cRFk6fxe; 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 S1729287AbeIMSql (ORCPT + 99 others); Thu, 13 Sep 2018 14:46:41 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:45593 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728540AbeIMSqk (ORCPT ); Thu, 13 Sep 2018 14:46:40 -0400 Received: by mail-lf1-f66.google.com with SMTP id r4-v6so4807484lff.12; Thu, 13 Sep 2018 06:37:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ZUDSm2FD2hYYPP2BfK4f9rXkC1bUeU5Jp9/jFHeXBjE=; b=cRFk6fxe9M+eVBuzMZS3cHsE1uetveMMfNiiEMHxtdjc335aE5bReGV+11XZwjBi2M Qt/WrRM1fpe8wyW4cmBo4TlRyC1fbYNBtTxWxCYXGirWDlkHBwPwoF8aRjIyvKkOVinj 9q79FQ5aVS7+m7N7O8xAY1iW+CKlTazT6dOrIkbkHlqruK2Dbs8bpB1vl5V13nFoOcUo 15v1j7qA8LcvDM/te1edM0TygLynbJny0N6Kv5xXh8nPEmYZSXPYCNH3Qd131seR6FfL hwZRD47mMlRfgT1ePb00O/4oIfSEFZ6EHHTrzWsM30uCvZnk0GiVrrj6HqKwvYHdiFKO PUKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZUDSm2FD2hYYPP2BfK4f9rXkC1bUeU5Jp9/jFHeXBjE=; b=Xgk/6KS/eelkbXHYjIdLC8nL3qX7mO0TXyFo08WJGKkuGE94F6/ZJ0S+/GmGY76iKl gzJkaU+Pk5gcn8PR4AGfQh+z5hS+fuKI4XjnFG6PTuxHRYVvThvXJg8tuhEwXxy+wXjN nBvSdqtZg6cYJIx3Y4wp4pg2MExouDtLEE+jw19NgcVC/2Y0Oo6aV/VAZbJ+ZKd9dMui XpGWAv66dHPbkl4mHBz72Xcp0KXjjDzQ0kiLg5xurilOJkBDM70fAZ3jhE2qhxI6VOWF nEcS2b8/4zXPalkQ4tw9Q9XRJS8eJ2NM0c89C5FgjJxk7qiQwr4Ji38t67WWAit8uZB0 C5Ow== X-Gm-Message-State: APzg51DBJIWt7psnl7x/IFdP9orloMmYETJi5mLVaZty6nJHzjnt/Fbk L1ZJy7doRsAPs4Ieems6sfM= X-Received: by 2002:a19:ea52:: with SMTP id i79-v6mr4710803lfh.75.1536845828033; Thu, 13 Sep 2018 06:37:08 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id 96-v6sm750026lfu.40.2018.09.13.06.37.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Sep 2018 06:37:06 -0700 (PDT) From: Ricardo Ribalda Delgado To: Linus Walleij , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado , Timur Tabi , stable@vger.kernel.org Subject: [PATCH] gpiolib: Free the last requested descriptor Date: Thu, 13 Sep 2018 15:37:04 +0200 Message-Id: <20180913133704.15739-1-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.18.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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