Received: by 10.213.65.68 with SMTP id h4csp44947imn; Mon, 19 Mar 2018 19:01:51 -0700 (PDT) X-Google-Smtp-Source: AG47ELsESFCl2QBvjJ4hHFCNvh/L3Hbf35PY7SO0wMPsmOzAKuQvWAaDv2NqmcFSIDY6FA7lAChN X-Received: by 10.98.182.26 with SMTP id j26mr11940700pff.223.1521511311822; Mon, 19 Mar 2018 19:01:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521511311; cv=none; d=google.com; s=arc-20160816; b=e5uqaL9/2WsIHPUG4751zxcqC4pyoOAx8Zd3wuZ5Hxmpzt3lJTYpCgrwyLOI7xzkF3 cZCFL1M06XNZRIPbHqhbjzo9zz+qShi+C5K1NDSECrBZkw6kmo6fBNVJflseJEtePFIy dwpt2RYljSFfxpjI+zTqwC2h8Q3B2EjENC2W+3x5OCXGXjdwoIXUHFPIVjC6FAa6RRIE KD3Hu+C/XblhN8r0QZNdJQUxz+eBVPZk2gyty0FQvdvu8po4CnVYiqsUlq8zOZYXVpps 5o4EytZbRT7lxZEn6hZrHWm2pyl3an/2jm/v6/7TbEpNE9pQmdSk4LO+QxvZ3KDmoTsP Xjpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=h/dSJO8G/yJEcA0R3COvCO11OnFoGj1fkQ3z8Pfg7jA=; b=zOe1XHwV4jDD92DB6Gtgy3oNbu0a5kuucNttJaC2sWeKMd5fWrnVYqvik7Be4BP8q2 5TsJWRsEwJz7TYEx1NxFezeaJbZ40TwYJjogKlB/KeWBUjHlxWGXH+oA/BuhQDN9Yvaq JQSZfJzcByAO/Hxwfyr6ciPcxb1f+7EMGtcyebxZoVdQAHSX2ubcMdb2IuE6O+N8fCaY hC+G+QkQPWumlqk3oYK1VzA4YnxI8fdHAdKx8t8EwW4PxMLiOJab6RAMUVbk5neTdbRy hzmKlcUx1WIQUZHUwL6bGd2v3dRbjeNEEZ0U/rI6/4Y7UUG2O40l7tH3oxJIQ1GrTLxk d7mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=PhFotW5p; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u19si426814pfk.128.2018.03.19.19.01.36; Mon, 19 Mar 2018 19:01:51 -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=@microsoft.com header.s=selector1 header.b=PhFotW5p; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032619AbeCSWhq (ORCPT + 99 others); Mon, 19 Mar 2018 18:37:46 -0400 Received: from mail-co1nam03on0122.outbound.protection.outlook.com ([104.47.40.122]:59200 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933458AbeCSPrg (ORCPT ); Mon, 19 Mar 2018 11:47:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=h/dSJO8G/yJEcA0R3COvCO11OnFoGj1fkQ3z8Pfg7jA=; b=PhFotW5pDJznu4wWNnsnro/d8aJ9hfotJYEe0hAl8GUIrWP7e/p+I+K+V5JJjAu+V1P8nxnKEYWdeFFaMstfIkhBm2lbRxyo4qtZeOAyMiyn0hN48lh0wkkCmW9myHrEFVfBMj/xKgbGQDryW+shrVByzHzcmovD/612657BlfE= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0998.namprd21.prod.outlook.com (52.132.133.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.631.0; Mon, 19 Mar 2018 15:47:29 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62%5]) with mapi id 15.20.0631.004; Mon, 19 Mar 2018 15:47:29 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Vladimir Zapolskiy , Linus Walleij , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 027/124] gpiolib: don't dereference a desc before validation Thread-Topic: [PATCH AUTOSEL for 4.15 027/124] gpiolib: don't dereference a desc before validation Thread-Index: AQHTv5mUkSrK8FmWmEenI7Ey7hyD7g== Date: Mon, 19 Mar 2018 15:47:26 +0000 Message-ID: <20180319154645.11350-27-alexander.levin@microsoft.com> References: <20180319154645.11350-1-alexander.levin@microsoft.com> In-Reply-To: <20180319154645.11350-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0998;7:dQSOKHa2Yw08B5YjXi2Y3vlIWCtZ65s29yJMHuSdXNko8KZe96xFOD+/CQrvoIBVWCLgD73yytshTlGMiw8kognaBev4pcMx1ggvbESO+yiuzdstUPBj2b8JD6hx6dI2gO5bvDqlZAGYsROVv55XeYz77zLww67Ap/b513Yeks83wHG2gZtaNASq5wuVfv5oGb4pGVzZqSD3Ef5uvENts2vqiHDZv8/hlqWcvTw6q/5XFxXB82mU5E+uJmrS3OhG;20:fW0fKbgbmjbY5kDc9CvJN53XOhrWJfVzf7R1DOIzQCy/sROhOGvtY6qELy4a9Qen6kJawwfcY2En8ff1+Wc1G2621G2zbwRL6aLPCJ4YUS8pDqNI1yGUv98B4Rbi70ma+wcpxinlLM/UfbSYWB2zESNVQLmuYIrpEmnXzdPOZcY= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: ecf5ab6f-aa1a-47f4-a2b7-08d58db0b8c9 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0998; x-ms-traffictypediagnostic: DM5PR2101MB0998: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231221)(944501300)(52105095)(3002001)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0998;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0998; x-forefront-prvs: 06167FAD59 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(39860400002)(366004)(376002)(396003)(346002)(199004)(189003)(3846002)(6116002)(8936002)(6486002)(102836004)(68736007)(6506007)(2900100001)(22452003)(25786009)(3660700001)(7736002)(76176011)(6512007)(72206003)(86362001)(575784001)(53936002)(8676002)(81156014)(6436002)(81166006)(305945005)(478600001)(99286004)(2950100002)(14454004)(6666003)(10290500003)(186003)(107886003)(2501003)(106356001)(26005)(86612001)(97736004)(5660300001)(10090500001)(110136005)(54906003)(316002)(2906002)(66066001)(105586002)(4326008)(36756003)(3280700002)(1076002)(5250100002)(59450400001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0998;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 8eEG6clU03uh3HpbPCpZF3ATkjlWPN81/+XjcwVjVanXiWVYekpPWoXY09W5wb1dZkW6VoANpK+bk1PwXDvuP4yfqZ15bnBnpFK9zju/AWRn0AME8yBDEsqoMVO88ZOTk410GGZPV3H9AAz2sr3RYtgFGhv2DIyXaJ4jYdknimL5e/Dfn0H7e9NYJEsd7CHEpI4z3iEB8Ja2Khgsc06rqYgJsWZ0tWW3JMotYfxFhhYI1KcZtdIERKkuB7KwMX4trQGqIAwK5jzKm3AsJb5NDHOp/2gbtdMNnFvy8KKwFs8Q8yUl2MlOGAYDqski3gzyV4f9oMseuLFqlEEisf+TEw== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: ecf5ab6f-aa1a-47f4-a2b7-08d58db0b8c9 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2018 15:47:26.9006 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0998 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/gpio/gpiolib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index f6efcf94f6ad..8abdd0035091 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2459,7 +2459,7 @@ EXPORT_SYMBOL_GPL(gpiod_direction_output_raw); */ int gpiod_direction_output(struct gpio_desc *desc, int value) { - struct gpio_chip *gc =3D desc->gdev->chip; + struct gpio_chip *gc; int ret; =20 VALIDATE_DESC(desc); @@ -2476,6 +2476,7 @@ int gpiod_direction_output(struct gpio_desc *desc, in= t value) return -EIO; } =20 + gc =3D desc->gdev->chip; if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) { /* First see if we can enable open drain in hardware */ ret =3D gpio_set_drive_single_ended(gc, gpio_chip_hwgpio(desc), --=20 2.14.1