Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3933679imm; Mon, 8 Oct 2018 11:56:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV60U3HVeogIgF94kIovjUncEkHbteTM6pk+Wki8zB/w8t/MjuGBN+7iZ89MAzGb4Z1342fee X-Received: by 2002:a62:36c3:: with SMTP id d186-v6mr19516870pfa.133.1539024962589; Mon, 08 Oct 2018 11:56:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539024962; cv=none; d=google.com; s=arc-20160816; b=gw6NQvC+FN0VMwz1LtcfC6iyvEZ0u8Em+GPKzKa0cFS2cipWwApYYPQSOPcHbERS1c 77BU5pIk21nc3ZVhCW46YGwZuhOP2waqOirHT6AyVP0ZR6SJ2q6kRYXyznS65HgqQCxE jQKCuwR0eI7uooqLj46wZD5J18wJ15eZevNVrE6gYWhaVPFv2AB5L5bKo73soo5xPLpw 6QAXXF3KIW8lTMWyw9pomMNs7OZIgHgQQzkpHJtZ100BTpaXfcVPvXM3xP/B5GTUwLdS nn9LSriWgrEDlfgP4QhNtPBxLOu1BF4pZatRiPnwGTa9Tt61qOk/MWlYv9n+s1jZRrIk 5jGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rxBE/StqAKwmIb2FP9HLptnyNuRi0liOUglJt75q8+w=; b=J4WmAmoDtPVTRBXhrnVMa1Y8U1iTN43P7+7n1Y9R8A4JaniE1JBJpxiFGwyouR1LFv g+yFyFxQ2UpqczwDoc6KsdekpD7khvmZKUzSGbv8lzILjDyTeMzeJnElHbgRezIh3SIe BbtJuTMbh//WTOu42AVAkc/hcf9jzKvELVjuMxFADm+6n1IQe1INP0h72QExnF5aiY7i I4CqwZpscJJUezBWYMsnvzRrz3YnyODyLaF5MP8LWAOqP94dJya2cMqVYR5fgFkOCFMq r/pAP2QUcVo7U2zZj6E4n7ZUZvUEFIuKbTEHDz9Ed8qiBpkQn/Zbfpw7z6qtFfreakZ/ kwDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LuC1vr1X; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f34-v6si907967plf.161.2018.10.08.11.55.47; Mon, 08 Oct 2018 11:56:02 -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=@kernel.org header.s=default header.b=LuC1vr1X; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732785AbeJICGo (ORCPT + 99 others); Mon, 8 Oct 2018 22:06:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:57108 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732457AbeJICGm (ORCPT ); Mon, 8 Oct 2018 22:06:42 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D6AB92087D; Mon, 8 Oct 2018 18:53:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024814; bh=upZJhyvuQR7i0+eTSgS+8Tj4GN+Vi4ZXvKQI3gk3h/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LuC1vr1XHB5huWxmu6Xd/JM2LICD7Tyxh+6zEuPuYyKf4BWe6/BgmiyQ/ZI82YHp7 NXjG0qc3QCR8HqKUygykaQ8LIdZF4IMTHeLwgGVcgQvRt7nD5j11Erx+38HBTJSttS SnUJRk3j/flcBUbwfgOtboAMBt3CBn14eyXqMqB8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Timur Tabi , Jan Lorenzen , Jim Paris , Ricardo Ribalda Delgado , Linus Walleij Subject: [PATCH 4.18 162/168] gpiolib: Free the last requested descriptor Date: Mon, 8 Oct 2018 20:32:22 +0200 Message-Id: <20181008175626.216039559@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ricardo Ribalda Delgado commit 19a4fbffc94e41abaa2a623a25ce2641d69eccf0 upstream. 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) Reported-by: Jan Lorenzen Reported-by: Jim Paris Signed-off-by: Ricardo Ribalda Delgado Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpiolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -565,7 +565,7 @@ static int linehandle_create(struct gpio 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);