Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4877496img; Tue, 26 Mar 2019 19:48:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+kKJhJM/bJ8ZPbHQEN8KrilGU+0YYcRXm4Aqyw19QrLCYQpnoqtjGxXkbbb1RyiOsKQiv X-Received: by 2002:a17:902:4827:: with SMTP id s36mr363243pld.296.1553654895811; Tue, 26 Mar 2019 19:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553654895; cv=none; d=google.com; s=arc-20160816; b=zQxivhVE5M62Ce/uDVie27DlmLV7bD6BKJM7u+7+n9CeQv/HnPJ23jAAxTXSKO4FAR eOxVO1jjTFEUakC/BLAar1CNfj/aeTIwau5qapORnd3u8FyrC6yCpq2aWX0/wlZcRezQ Fv1RvvVSZ4lCAIQjy4G+Zrcv4b7BCv9cnkL7sU1c2rYXmvwrr/TSv7+GbeLDzWGOKYb+ /4u5MPJgi4LIP90HpgGfeVuX9Gg+6hpnuJwI2z09mKR/1ImxYVpfAh6VQLs7YjlFUn3S WuR3nadUigsDduu24pA4I09sZoh8X8n7KBEI6XpPg2YLe2yNP7gBm7QAP0qUpjf4SI+G Wu8g== 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 :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature; bh=Hbg3foC/yowp2bJcbBIMVtNzDRCCuchdl3PJzaeZjEk=; b=HHdUJBmsYa3LVkt0x3kdWwv3qvj47oNXUBGqXT9zfuvMnsbr249Prqd2/goV2/tSHb txa5cSlEd92gXE/nm2DLFH+BL5zOAQaxCqWyViJevvDS57hjzGQ6QqHq6pAEbPXzB+/z +RzuxXn3NWjpSyCHKAM5/wXq6/RoiS4dvUZSme3YXi2ApIU0Aq4Du82EZOW3BK1R9/J/ NtZwRn/8TTxxTkZ7J5SGHxmI1o/OtN+UA8mLoMgI9Fy8gAPyUIrM6e3vWxb9zICUlFxT nGgu+jW9P2gw4KxywC9zuatUw1YvQE0uHVKU4WiAIR8R/3Kzntwb5mi3ViVwkge8Xk6a xX7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b="oQnfOhJ/"; 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=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1si1536456pgf.254.2019.03.26.19.48.00; Tue, 26 Mar 2019 19:48:15 -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=@nxp.com header.s=selector1 header.b="oQnfOhJ/"; 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732709AbfC0CrL (ORCPT + 99 others); Tue, 26 Mar 2019 22:47:11 -0400 Received: from mail-eopbgr140075.outbound.protection.outlook.com ([40.107.14.75]:52704 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727532AbfC0CrL (ORCPT ); Tue, 26 Mar 2019 22:47:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Hbg3foC/yowp2bJcbBIMVtNzDRCCuchdl3PJzaeZjEk=; b=oQnfOhJ/4WRiVSMdpv4aH1B+7m6AJK/hM83vKJLvQvJI6ngdJCJcKAJBHW5ryzFQHxPKJcSpEIHRW9oX66AtMxnwk3ddeVoBcLiX053aN9zMVk2tvbKYhGV1CJMeBOfXr6AzJhq6Bw3qnZ0/m3lXfCq2p1fpOMKRTRbiiT19TEU= Received: from DB3PR0402MB3916.eurprd04.prod.outlook.com (52.134.72.18) by DB3PR0402MB3643.eurprd04.prod.outlook.com (52.134.66.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.18; Wed, 27 Mar 2019 02:47:06 +0000 Received: from DB3PR0402MB3916.eurprd04.prod.outlook.com ([fe80::f1b4:a1fb:cfd1:3f08]) by DB3PR0402MB3916.eurprd04.prod.outlook.com ([fe80::f1b4:a1fb:cfd1:3f08%7]) with mapi id 15.20.1730.019; Wed, 27 Mar 2019 02:47:06 +0000 From: Anson Huang To: "dmitry.torokhov@gmail.com" , Fabio Estevam , "linux-input@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: dl-linux-imx Subject: [PATCH] input: keyboard: snvs: make sure irq is handled correctly Thread-Topic: [PATCH] input: keyboard: snvs: make sure irq is handled correctly Thread-Index: AQHU5Edd/2+nSp1pAUqjt9pZVWLgMA== Date: Wed, 27 Mar 2019 02:47:06 +0000 Message-ID: <1553654517-7810-1-git-send-email-Anson.Huang@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-clientproxiedby: HK0P153CA0002.APCP153.PROD.OUTLOOK.COM (2603:1096:203:18::14) To DB3PR0402MB3916.eurprd04.prod.outlook.com (2603:10a6:8:10::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=anson.huang@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6d2af989-8dfa-430e-0dfb-08d6b25e8015 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600127)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:DB3PR0402MB3643; x-ms-traffictypediagnostic: DB3PR0402MB3643: x-microsoft-antispam-prvs: x-forefront-prvs: 0989A7979C x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(376002)(346002)(39860400002)(136003)(366004)(189003)(199004)(99286004)(8676002)(6506007)(6436002)(81156014)(14454004)(102836004)(186003)(478600001)(386003)(5660300002)(305945005)(26005)(2616005)(316002)(81166006)(486006)(97736004)(2501003)(4326008)(71200400001)(71190400001)(52116002)(106356001)(36756003)(7736002)(14444005)(476003)(6512007)(25786009)(2906002)(256004)(3846002)(86362001)(8936002)(6116002)(53936002)(110136005)(50226002)(2201001)(68736007)(66066001)(6486002)(105586002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB3PR0402MB3643;H:DB3PR0402MB3916.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: xuwgKWVenKsVeB2VGUjda7+JndVKiPycHhvXDNV7KZEpUfovSPuG6DApFm0fveTd+NfMKebr4yfxrWcot6ofnpNw4AYfn5R7BUssMaMxgopOf4/1bRulyrmjuJ+w+NCxztjoy+tJQ5V8yJyZjLStFpVaMTS2pyRvUoG2+saJSFsUpR9IdBc+qM/cV4jAFL0EcKwAuOTEwMrLmtu7kzhqJFlS1do7v5vhSImxaPoMAaEG3Tfng5qGSxQ7j0xbRWtn9Yircr7bo3grBw/VgUuvVKRZciaWYHOvuRHvgprgnFnX6i1do7slMAdf5ApD4CAjzM8PS6ipS0CoJXqepqBQ1RPKAdX8f3eridueMZa+JGhrry1VyIs01rCQ0fe4OYu7nG/J2tk3K5uRgw50e55CQB8N0puu5937390gO3FqWtc= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d2af989-8dfa-430e-0dfb-08d6b25e8015 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Mar 2019 02:47:06.8769 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0402MB3643 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org SNVS IRQ is requested before necessary driver data initialized, if there is a pending IRQ during driver probe phase, kernel NULL pointer panic will occur in IRQ handler. To avoid such scenario, need to move the IRQ request to after driver data initialization done. This patch is inspired by NXP's internal kernel tree. Fixes: d3dc6e232215 ("input: keyboard: imx: add snvs power key driver") Signed-off-by: Anson Huang --- drivers/input/keyboard/snvs_pwrkey.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboard/= snvs_pwrkey.c index effb632..6ff41fd 100644 --- a/drivers/input/keyboard/snvs_pwrkey.c +++ b/drivers/input/keyboard/snvs_pwrkey.c @@ -148,15 +148,6 @@ static int imx_snvs_pwrkey_probe(struct platform_devic= e *pdev) return error; } =20 - error =3D devm_request_irq(&pdev->dev, pdata->irq, - imx_snvs_pwrkey_interrupt, - 0, pdev->name, pdev); - - if (error) { - dev_err(&pdev->dev, "interrupt not available.\n"); - return error; - } - error =3D input_register_device(input); if (error < 0) { dev_err(&pdev->dev, "failed to register input device\n"); @@ -166,6 +157,14 @@ static int imx_snvs_pwrkey_probe(struct platform_devic= e *pdev) pdata->input =3D input; platform_set_drvdata(pdev, pdata); =20 + error =3D devm_request_irq(&pdev->dev, pdata->irq, + imx_snvs_pwrkey_interrupt, + 0, pdev->name, pdev); + if (error) { + dev_err(&pdev->dev, "interrupt not available.\n"); + return error; + } + device_init_wakeup(&pdev->dev, pdata->wakeup); =20 return 0; --=20 2.7.4