From patchwork Sun Nov 11 22:15:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 10677883 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 67E3D14DB for ; Sun, 11 Nov 2018 22:15:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BF282A124 for ; Sun, 11 Nov 2018 22:15:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 403872A180; Sun, 11 Nov 2018 22:15:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B229C2A124 for ; Sun, 11 Nov 2018 22:15:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Ly2Zp/VbcQbyuPbjZzSJh2qH0nayZUuUoUc3KfwHIBA=; b=DS1uGfB9zbEwHS ybq9gHURPbYUTzxggvhQl+n3uKYnkItIZMLjVgP1W5JButQ5pjGrbLbPAvP4G7sM/uxc7EM082fuF JyXv8t0yXSmr7PRNgLQ6GCDSeRLuY6eD5eGjoKllEKgdt/gMWATfinjol01y+5SEPh9kqhjbeUvfw HqckfO6LBiWPT77D+A9P55bKVzq9idydGxBi69oH6tIEFjAeZYCJSq0HeutVYfG+eSAL+3qyVdxt0 pKPLY7Y4UQReopEBEv1FzhfaeoNFksrnTXwOq+Hng9DqM76Ue2r1vTD1bqNIQSNoBTZFQo8BADsRk Bss50/VnE4qgUSfcnXKw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gLy14-0001Ac-67; Sun, 11 Nov 2018 22:15:38 +0000 Received: from mail-db5eur03on0603.outbound.protection.outlook.com ([2a01:111:f400:fe0a::603] helo=EUR03-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gLy10-0001A0-Fo for linux-arm-kernel@lists.infradead.org; Sun, 11 Nov 2018 22:15:36 +0000 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=SQDQ/vqzrmjH9tlGxVaazwJVbVY+VLsE7NIwyPrZ/bE=; b=c5gYRsMfuqU4oXWJb5+7V4UFBpv+eeWMrfPElYkUgcviHAKj6f7j++5Yv7+dSnHZ5jUoTQU6Nx7M+T3JBa3/aVHPL0jPew3PTLGef+OyauRB3HI3W+PQ3TbsJezof8e5sS3EZjJrSuqI1k46zEarpUv3e1Eq+kCgiFXLnkIRqlg= Received: from AM0PR04MB4290.eurprd04.prod.outlook.com (52.134.126.145) by AM0PR04MB5105.eurprd04.prod.outlook.com (20.177.40.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.31; Sun, 11 Nov 2018 22:15:15 +0000 Received: from AM0PR04MB4290.eurprd04.prod.outlook.com ([fe80::a059:70be:9c00:a3c4]) by AM0PR04MB4290.eurprd04.prod.outlook.com ([fe80::a059:70be:9c00:a3c4%2]) with mapi id 15.20.1294.044; Sun, 11 Nov 2018 22:15:15 +0000 From: Leonard Crestez To: Linus Walleij , Fabio Estevam , "A.s. Dong" , Martin Kaiser Subject: [PATCH] pinctrl: imx: Fix imx_dt_node_to_map handling of IMX_NO_PAD_CTL Thread-Topic: [PATCH] pinctrl: imx: Fix imx_dt_node_to_map handling of IMX_NO_PAD_CTL Thread-Index: AQHUegwFC+uQPU3MeUSeLA6WfZhBcg== Date: Sun, 11 Nov 2018 22:15:14 +0000 Message-ID: <1547d44dba63cbfd1b813018866f8916013b3381.1541973902.git.leonard.crestez@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [95.76.156.53] x-mailer: git-send-email 2.17.1 x-clientproxiedby: AM5PR0402CA0021.eurprd04.prod.outlook.com (2603:10a6:203:90::31) To AM0PR04MB4290.eurprd04.prod.outlook.com (2603:10a6:208:67::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=leonard.crestez@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM0PR04MB5105; 6:tKWYtyjARD1Wa7TyZymW0UgKhM1nP8xauKZBqL1akq7r13iErLbe4yo6EDpsaAqNl6AtayMN9PhIOalXsdm+B5Rpz1L9SQdperzQC8Vwbx/L/4uzqeVfQEmBc+0WQKjslrAXbFWH9bsVpmB8DUmNFYE3VPADnnvTYd1FhLscv07N69sjELUdOPO45vnxnh9xxmWp8l0XsfW9evTjKHZSTqafnvWsXLCf4N7RInryiHXlFzECcIn4ubxNnu7CGQb28gmguw7JIx1jke9ZQmGx27n3DbDPY9LYlXyhsFnMEYB532kLM28IcjkTCuwHOxt7X3RhxsUau4MdTdDuux1JTjT9HJSAaU15RWT0IWTqBSWMeqgx/MAReZDROn+AAmaMYvsKdjrHGJm7/t8tbFwTsNlmTw6EM38gt8hP5ikQ6WsUmLjupxVrp0YONod5xEDser6rVutc0FEZqQnfOVIcbQ==; 5:Fr5atyg5G0c2aHHJ3FH2XTMWe0RF514DBnmbsyZNv89fGpRmngnwYKSrEF3Ej1+GPZ2f24zlc8W2cD8qTQttWuVliXp5nBJ3lkJw/3yL4Ozob9gXmsz/W+y/ekE10TgwT4ahYU/a2iJFtxGeG8sCiQJMP+X2aDXibOyJJHQRs60=; 7:Jo5q2J0gRrYu35B6Jod7TiGu064ddCge+PHVz9txJvxCOcDpnO10z2t51so9whNn2dDnfwgtEegY1gsJlrInhCRmVbR3rCbp+zvXHE3ZoK+OyWO0LGlbxapiUIVaYhCge86ge4BoooHsdQFUFkhh4A== x-ms-office365-filtering-correlation-id: 3692b73f-1a7c-4812-234a-08d6482327ab x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390040)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:AM0PR04MB5105; x-ms-traffictypediagnostic: AM0PR04MB5105: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3231382)(944501410)(52105112)(3002001)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:AM0PR04MB5105; BCL:0; PCL:0; RULEID:; SRVR:AM0PR04MB5105; x-forefront-prvs: 08534B37A7 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(136003)(396003)(376002)(346002)(39850400004)(199004)(189003)(476003)(8676002)(81166006)(478600001)(81156014)(2616005)(99286004)(6486002)(8936002)(36756003)(256004)(44832011)(6436002)(486006)(6512007)(118296001)(6306002)(97736004)(50226002)(71190400001)(71200400001)(86362001)(2900100001)(2906002)(1857600001)(68736007)(966005)(6116002)(3846002)(6506007)(5660300001)(14454004)(386003)(102836004)(4326008)(25786009)(26005)(186003)(305945005)(105586002)(52116002)(316002)(66066001)(54906003)(110136005)(7736002)(106356001)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB5105; H:AM0PR04MB4290.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 152jbvNCTM8687Dr7vI7mS3bfSZSr0cTUFJTZwz+/eJ8x3Q2c8uiL0F8wSI5akpiX8R4zLcrvxC2JAqujbPp4Pp3fsN4T1DcvtLz0v895oos/gr7qajInFFS6x8EG2T1pFIM46ii+P7I3GhdpaN5zPiRMzqx5vLRi4ERLiEZcIfHZ2Jid06CQ2JetFJspkmwYGWEeH35FczF9XPuZoaOdJ6m0f1KLWKraEVgRFetLe6qYftxK74J43C+783UaS3o1WyPtRoFPsQVKwi8q0P97i5gKQyxZnjWxAQIeihBCs2oe3aoP+zmbBrQQ8BmxvdyUqgWhQV3TgfZhqQJf76ezRUpdW9L/Wz2b6vhMzULhCc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3692b73f-1a7c-4812-234a-08d6482327ab X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Nov 2018 22:15:15.0148 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5105 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181111_141534_932166_2480D577 X-CRM114-Status: GOOD ( 10.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "linux-arm-kernel@lists.infradead.org" , "linux-gpio@vger.kernel.org" , Shawn Guo , dl-linux-imx , "kernel@pengutronix.de" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP After changes for SCU support the IMX_NO_PAD_CTL flag is not longer handled correctly in imx_dt_node_to_map. Pins with this flag are no longer skipped and the new_map array can overflow and corrupt memory. This fixes imx6-sabreauto boards failing to boot. Fixes: b96eea718bf6 ("pinctrl: fsl: add scu based pinctrl support") Signed-off-by: Leonard Crestez --- drivers/pinctrl/freescale/pinctrl-imx.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) A different was posted earlier: https://lore.kernel.org/patchwork/patch/1009504/ I don't think that's correct because it assumes num_configs is zero-initialized but new_map comes from kmalloc_array. Code is clearer if SCU and MMIO paths are separate. diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c index 78d33dfb4d2d..51312e81eff7 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx.c +++ b/drivers/pinctrl/freescale/pinctrl-imx.c @@ -106,29 +106,31 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev, /* create config map */ new_map++; for (i = j = 0; i < grp->num_pins; i++) { pin = &((struct imx_pin *)(grp->data))[i]; - new_map[j].type = PIN_MAP_TYPE_CONFIGS_PIN; - new_map[j].data.configs.group_or_pin = - pin_get_name(pctldev, pin->pin); - if (info->flags & IMX_USE_SCU) { /* * For SCU case, we set mux and conf together * in one IPC call */ + new_map[j].type = PIN_MAP_TYPE_CONFIGS_PIN; + new_map[j].data.configs.group_or_pin = + pin_get_name(pctldev, pin->pin); new_map[j].data.configs.configs = (unsigned long *)&pin->conf.scu; new_map[j].data.configs.num_configs = 2; + ++j; } else if (!(pin->conf.mmio.config & IMX_NO_PAD_CTL)) { + new_map[j].type = PIN_MAP_TYPE_CONFIGS_PIN; + new_map[j].data.configs.group_or_pin = + pin_get_name(pctldev, pin->pin); new_map[j].data.configs.configs = &pin->conf.mmio.config; new_map[j].data.configs.num_configs = 1; + ++j; } - - j++; } dev_dbg(pctldev->dev, "maps: function %s group %s num %d\n", (*map)->data.mux.function, (*map)->data.mux.group, map_num);