Received: by 10.192.165.156 with SMTP id m28csp20658imm; Tue, 10 Apr 2018 15:31:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx484kEPO/5MIzjifnUURCwjzfdyQx7IG9xemWCjc3G6w2FSI7cYEgdZg+d78Js+8TCV7uQY7 X-Received: by 2002:a17:902:43e4:: with SMTP id j91-v6mr2277928pld.118.1523399506613; Tue, 10 Apr 2018 15:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523399506; cv=none; d=google.com; s=arc-20160816; b=rnHNHQsH4PewP2zDJBvUJW4/ZyJXQOmnJ/iHN49tht8Ymy3vyWNSmfyzuiQr9Ifojp Y2jUP6Y0wXS0Ltiu4Fz/uCWh4m0RLORKyrS/XRGcruBVs+h/zF8UrF1Q7i+My0lmi1kZ bW8kkGMjIpCsrQUJ6v0EJvHbvolcv97cw3cNB9I7HE78olj/6AYkn3CpGM/TaE/p16K1 TDFIN/g9Jq4SX4uqm2SpN7o1vd+ApcYuRGo6CGBe2uKZuRkOqh1btDcZ+gvSYDJjfrD3 97Z+ROQGpA1E3r108T/iq++QQLrJidhleh1dbn6BrZUYX/vBsMeUdHx3rzdL99bpmJw7 J3aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=02goJXRJV08t8t4KUugfduPY/JO7MJbA9MUGDt+IxkY=; b=bYgEAw/U+6m4JcJOe6Gqg8mJ3LsKYlU6JHVA9zXyMOyNIbgdR9+9cBBlfk6j4rHaRe JAbsDtzOG9zFZJPYo5swBklzDwAi/UFEV4zSNkI9/9OsutfA4c+gPuZpNvUdZSD91jsj Sj6USCxl/kSdHQzCeMG5NDsL+0FD2tCo3mEgxIS+60L9hgkq0iYDxMbQZ0bmMu3qNNlJ 8rN1KBia+dafuyqGzV+o1lDYx1SfwKzx4waA4OTySOxJRX7kx3t2bH8bPvZoZ4L58dXt 9Xd6gudQEA6oQdw3CtFR6ewsQdWUJDGUS/ieF/k2xTa5HiaodS/YRVc9648L7qJ/Z3kW f36Q== ARC-Authentication-Results: i=1; mx.google.com; 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 a8-v6si3452657pln.234.2018.04.10.15.31.10; Tue, 10 Apr 2018 15:31:46 -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; 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 S1753323AbeDJW0v (ORCPT + 99 others); Tue, 10 Apr 2018 18:26:51 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37618 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753241AbeDJW0r (ORCPT ); Tue, 10 Apr 2018 18:26:47 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3FA03CC4; Tue, 10 Apr 2018 22:26:46 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Zapolskiy , Linus Walleij , Sasha Levin Subject: [PATCH 4.15 025/168] gpiolib: dont dereference a desc before validation Date: Wed, 11 Apr 2018 00:22:47 +0200 Message-Id: <20180410212801.267806966@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212800.144079021@linuxfoundation.org> References: <20180410212800.144079021@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vladimir Zapolskiy [ Upstream commit 30322bcf82d74cad0d6e1cf9ba7fa7fa48c7a026 ] The fix restores a proper validation of an input gpio desc, which might be needed to deal with optional GPIOs correctly. Fixes: 02e479808b5d ("gpio: Alter semantics of *raw* operations to actually be raw") Signed-off-by: Vladimir Zapolskiy Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpiolib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2468,7 +2468,7 @@ EXPORT_SYMBOL_GPL(gpiod_direction_output */ int gpiod_direction_output(struct gpio_desc *desc, int value) { - struct gpio_chip *gc = desc->gdev->chip; + struct gpio_chip *gc; int ret; VALIDATE_DESC(desc); @@ -2485,6 +2485,7 @@ int gpiod_direction_output(struct gpio_d return -EIO; } + gc = desc->gdev->chip; if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) { /* First see if we can enable open drain in hardware */ ret = gpio_set_drive_single_ended(gc, gpio_chip_hwgpio(desc),