From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8E62C43381 for ; Thu, 28 Feb 2019 14:27:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ABDBE2184A for ; Thu, 28 Feb 2019 14:27:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=serialtek.onmicrosoft.com header.i=@serialtek.onmicrosoft.com header.b="RiANbnAI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727889AbfB1O1k (ORCPT ); Thu, 28 Feb 2019 09:27:40 -0500 Received: from mail-eopbgr750077.outbound.protection.outlook.com ([40.107.75.77]:63840 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725918AbfB1O1j (ORCPT ); Thu, 28 Feb 2019 09:27:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=serialtek.onmicrosoft.com; s=selector1-serialtek-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jdobtwgbIWjdsmBox0VnuAMkiWv6nvxEG5HW4P2vZxo=; b=RiANbnAIlDO6tZw1k4Ml5HHyYWIOPpswKraWOAsivewpbI+06VC6DPhLVnRdRvZbE733ufv4tly3mQAEFwqbysU05Nv4HJ0pEHg2NF58AvANFfgMd/O5ZgPpE0gqtx3UcgHxfJkZqsHrPUi6R0e+iJ10Z4aLb5uSf4hfbX/eCQs= Received: from DM6PR19MB2602.namprd19.prod.outlook.com (20.179.105.222) by DM6PR19MB2729.namprd19.prod.outlook.com (20.178.230.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.16; Thu, 28 Feb 2019 14:27:34 +0000 Received: from DM6PR19MB2602.namprd19.prod.outlook.com ([fe80::a456:6a2c:482:ed8e]) by DM6PR19MB2602.namprd19.prod.outlook.com ([fe80::a456:6a2c:482:ed8e%6]) with mapi id 15.20.1665.015; Thu, 28 Feb 2019 14:27:34 +0000 From: Mark Walton To: Linus Walleij , Bartosz Golaszewski , Marek Vasut CC: Mark Walton , "linux-gpio@vger.kernel.org" , "stable@vger.kernel.org" Subject: [PATCH v2] gpio: pca953x: Fix dereference of irq data in shutdown Thread-Topic: [PATCH v2] gpio: pca953x: Fix dereference of irq data in shutdown Thread-Index: AQHUz3G+LImDQQw84EiofELjlFAigQ== Date: Thu, 28 Feb 2019 14:27:33 +0000 Message-ID: <20190228142539.GA7744@mark-devvm> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: LO2P265CA0474.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a2::30) To DM6PR19MB2602.namprd19.prod.outlook.com (2603:10b6:5:187::30) authentication-results: spf=none (sender IP is ) smtp.mailfrom=mark.walton@serialtek.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [77.95.179.50] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a8de94e1-567d-4761-5ed6-08d69d88e0f8 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(7021145)(8989299)(4534185)(7022145)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020);SRVR:DM6PR19MB2729; x-ms-traffictypediagnostic: DM6PR19MB2729: x-microsoft-exchange-diagnostics: =?us-ascii?Q?1;DM6PR19MB2729;23:W3kJxP9FxlNuIf6Z251psnGN6FzvhT3prsOHCJHZN?= =?us-ascii?Q?Ku5yKPSFSeJzJ9MeZZGYMemVl7d9uqVKOzNCrGQdBEeSUijrcLHNQk62DAhW?= =?us-ascii?Q?IrfPOEysbxSxafzq0t8VTGOowL0hi13GX5BWmSWLQX4IBB/K4NhAhCAji7Sl?= =?us-ascii?Q?/7ZWEg994NwkKtpY0eDbtO58bQ2pVWx58B5AKl/N5Yz5RJujDdkDSVtZsX8X?= =?us-ascii?Q?NzCosYkc7LA470YtWFLaEaooglfRg2u0Lc99eOlm/C+y6tqLTeO5fzaVl7XM?= =?us-ascii?Q?kpyy6QnNyLoFEQvWgVSTjLVoxEEuuKELlYpB/du+6GRWy4wVAtAbQyVDHUPB?= =?us-ascii?Q?RyIWWHcjlhlDf6wqVQcf7DtaQEcZa45y5+6fO0apJSP2mHtWBO/OraNr81B8?= =?us-ascii?Q?RB5Lv4OuIzcnXJyg491zLhYZObaXVckdXR1wQDTNRDIiTTLbKDmumuAIalFA?= =?us-ascii?Q?ZwHkWB0GpqfZgytUjxpA56tum549XQBxPqp+uOtLva2Dl3aGdv4BY1SIWAU8?= =?us-ascii?Q?KA/6dhWWjviOV5haNA97VrqNlnLRKKrKmPd31ss0zcTzXPqDmoYOVbQCM+Ed?= =?us-ascii?Q?OzpImYMdVtYwdDMrI8v/WvSKV1pMYuMmHtm6Qh+KpkEL4/pwMXeX4YPzDKTj?= =?us-ascii?Q?UiVm/RHSW80IqMH4n8ITlXxexXQ5nkiy9y6W3m79ZBM+YA3GEw16i37GgG/j?= =?us-ascii?Q?XewOvqDHc+pGiFkjZzlQfFXValzH8kvu0SuBRJrD8qRGKVxvWPfQ6/cFgYbL?= =?us-ascii?Q?Ws88+tuAQ/Pi4F8cv01eeV7UOpRQ9sEzFmez9YHd0IjCNY75/mGgTVwvXyan?= =?us-ascii?Q?XezTUWSiVOwfV8mqIVQLEvyYvwmkxCjotaX9ez62GDdSad5KUikuYON2TauV?= =?us-ascii?Q?Yh381ew1nVH2YYSTHra8tiNvDLruynoEL7IXsrEO776tz57V9eoi1yN1bNB2?= =?us-ascii?Q?R4Caepw7S5mODPj8dE7JEjhqxz3cxJ/EB3GAXC5szK4hsR7pCozY3olmwXbC?= =?us-ascii?Q?Gllcub+BLp4cJjUaoRDQwCFpocxEndNG1RSxzeTO0lyEzLzvMIiorpacLNON?= =?us-ascii?Q?LK8emLUcUf0FS7FUNGWJDQawDRrvrG+sZTPKP5gZWkCLNLHNVs3tnKnewwQ0?= =?us-ascii?Q?t7USgsX/yqSyz1Whu78Jta7UN2khJlIemq/1SgcAY3s4Dp5AZQ9fWy1K7y7y?= =?us-ascii?Q?rVp8B1SgYkemowG8WdSaiKGtYF0I4ykwKUx?= x-microsoft-antispam-prvs: x-forefront-prvs: 0962D394D2 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(7916004)(346002)(366004)(396003)(136003)(39830400003)(376002)(199004)(189003)(5660300002)(1076003)(3846002)(508600001)(66066001)(6116002)(99286004)(52116002)(97736004)(386003)(14454004)(305945005)(6506007)(33656002)(102836004)(68736007)(7736002)(81156014)(8936002)(81166006)(8676002)(86362001)(106356001)(44832011)(33716001)(110136005)(186003)(26005)(476003)(54906003)(2906002)(71200400001)(71190400001)(4326008)(256004)(14444005)(25786009)(6486002)(53936002)(105586002)(9686003)(486006)(6436002)(316002)(6512007);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR19MB2729;H:DM6PR19MB2602.namprd19.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: serialtek.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: rgv1Fzsq/Yv/Cnt2DxBCYBgTu81kVu2HiUgNrSarvIo8z2DoMypgZIc3NTPyPKXRp275r6zuYuFEz+DEAjI1E+7HbBAzHgGBnUh+xvOPWYSFWAdNRyeUdQc6aalQMHNuXNOnlo32PynFJnDglwzTiMBsgJOSRACPkChLEYUeQibtW6E2DlsgQ4qmiHAhRpXgAYnaN7mUed4acgZriEc7KsE8HJjKnQ1ctn7oHKO5YRYGsXpH2zpsre8TS38kHEJ6sPWowOZVVqPnSNmoWIWejO/4KL2uVawSSM8auDIprk0LlxAWTSmq72e/oemK8HWPtc5cl9R7wBoFdet9cUiF5Th7bhNZ9EceDOennjFuSn7nNxY9hsQ8Ze3bxN9Sxwpmr0jKmZjETYxCOfhD3idtTXYHMkRvqsT8ZvL3i451sus= Content-Type: text/plain; charset="us-ascii" Content-ID: <3F40215C3148F64CA2CCC29C55F9F8CD@namprd19.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: serialtek.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8de94e1-567d-4761-5ed6-08d69d88e0f8 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2019 14:27:33.9403 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: fc4624e3-7cc7-424a-9340-858bc44a78b5 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR19MB2729 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org If a PCA953x gpio was used as an interrupt and then released, the shutdown function was trying to extract the pca953x_chip pointer directly from the irq_data, but in reality was getting the gpio_chip structure. The net effect was that the subsequent writes to the data structure corrupted data in the gpio_chip structure, which wasn't immediately obvious until attempting to use the GPIO again in the future, at which point the kernel panics. This fix correctly extracts the pca953x_chip structure via the gpio_chip structure, as is correctly done in the other irq functions. Fixes: 0a70fe00efea ("gpio: pca953x: Clear irq trigger type on irq shutdown= ") Signed-off-by: Mark Walton --- drivers/gpio/gpio-pca953x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index caf7dd1..6bd55a4 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -659,7 +659,8 @@ static int pca953x_irq_set_type(struct irq_data *d, uns= igned int type) =20 static void pca953x_irq_shutdown(struct irq_data *d) { - struct pca953x_chip *chip =3D irq_data_get_irq_chip_data(d); + struct gpio_chip *gc =3D irq_data_get_irq_chip_data(d); + struct pca953x_chip *chip =3D gpiochip_get_data(gc); u8 mask =3D 1 << (d->hwirq % BANK_SZ); =20 chip->irq_trig_raise[d->hwirq / BANK_SZ] &=3D ~mask; --=20 2.7.4