From patchwork Mon Nov 6 18:38:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trent Piepho X-Patchwork-Id: 10044201 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F38E0602BF for ; Mon, 6 Nov 2017 18:42:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E763D29F78 for ; Mon, 6 Nov 2017 18:42:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBF2329F7B; Mon, 6 Nov 2017 18:42:19 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E1CF29F78 for ; Mon, 6 Nov 2017 18:42:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753652AbdKFSmS (ORCPT ); Mon, 6 Nov 2017 13:42:18 -0500 Received: from mail-cys01nam02on0090.outbound.protection.outlook.com ([104.47.37.90]:45342 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753386AbdKFSmR (ORCPT ); Mon, 6 Nov 2017 13:42:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=impinj.onmicrosoft.com; s=selector1-impinj-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=aPSAlhMqIzFhoZu20UOP4lJpS3kbwoWrKjOiMjjrbME=; b=QqhrPxpqrCqPsHigEBqW1sdrXzNUSdEkc4H4EuRS6Ly4MMCBhpHoFD1f8z4eyxndEKgMyeIhYRaRVsdShLXhLCxXrYO0r18cf/8yJeE7bRh+/WmdQOKQgvsEwdhslOJlFljc9d3PQ0zPbfOOykCmv/Vs2d5xqvkUk0HJ8b9h+y0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=tpiepho@impinj.com; Received: from impinj.com (216.243.31.162) by MWHPR06MB2814.namprd06.prod.outlook.com (10.175.137.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.197.13; Mon, 6 Nov 2017 18:42:15 +0000 From: Trent Piepho To: linux-spi@vger.kernel.org Cc: Trent Piepho , Shawn Guo , Sascha Hauer , Fabio Estevam , Mark Brown , Oleksij Rempel Subject: [PATCH] spi: imx: Fix failure path leak on GPIO request error correctly Date: Mon, 6 Nov 2017 10:38:23 -0800 Message-Id: <20171106183823.3186-1-tpiepho@impinj.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [216.243.31.162] X-ClientProxiedBy: MWHPR22CA0012.namprd22.prod.outlook.com (10.172.163.150) To MWHPR06MB2814.namprd06.prod.outlook.com (10.175.137.147) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5c824fa1-0103-4568-7561-08d5254619af X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199); SRVR:MWHPR06MB2814; X-Microsoft-Exchange-Diagnostics: 1; MWHPR06MB2814; 3:jaouZMKzOvXVlga4hI8enwHsD7CDLl1PcDys2w9T386m5X+MFlVg/Kvu2Hv+7mBcmnd+AbmcxiH0QeVkfBPa63fPj9KLkLVYmQp81Cqc/H+LUN5tGswa761H1SsjuRGqx7DqQQDyHG9UMMBReeZA32MUc4fJ1mPVeoJKQ4n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Bk7nWcr1SRDfNhk5XCXGHk339OrElNJjjm6gxadoh0kyvMry2mHN7NhwlDRqZsOBY9zIkJXZLD1KXdScHfFniJ9vDup8eMB9A142WkItjN755B7j42LzgobYhnm5hT/DmCAbMSx84u+syTt7t0O3jfABTF0m/d0FFaZdMgffF9wYdo30n8WjXPoa0VtxZVC; 4:qiLHmfxnHzImEHo6CYX62MN5oKXgJDAwSZvkiyVizgZbc2KcSyM8zoKRAX6/MK3LOoJdGtk1vjZkiJtJjs3n1NFe4kfmKs1wvW7niHOCeITmvRYdsNRp2Ru4Z/0GXO6D76gMOOfsh4a32F+jNvh8I2dqHZrcz23dEP2ZPnVvYEN67MjPjRaUbaYbZrzDJpRg9uvCiLuans1p3aRdSEQgBa9ZEcQxqbUeXIT0lESPrLFBGBIO0jLJfzB0i2y/+xz9AakAxdrr8/R6Usv/q0juPoGydILb6M45exsrVh9v0lGrJ+eS5j396hK4yUGvY740 X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3231021)(100000703101)(100105400095)(3002001)(93006095)(93001095)(10201501046)(6041248)(20161123564025)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR06MB2814; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR06MB2814; X-Forefront-PRVS: 048396AFA0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(39830400002)(376002)(346002)(199003)(189002)(2906002)(50226002)(21086003)(33646002)(16526018)(4326008)(101416001)(76176999)(2361001)(36756003)(478600001)(66066001)(25786009)(1076002)(50986999)(16586007)(5003940100001)(105586002)(305945005)(7736002)(68736007)(316002)(3846002)(6116002)(2351001)(106356001)(6666003)(48376002)(55016002)(47776003)(54906003)(69596002)(81156014)(81166006)(86362001)(189998001)(2950100002)(8936002)(97736004)(6916009)(5660300001)(50466002)(8656006)(53936002)(8676002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR06MB2814; H:impinj.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: impinj.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR06MB2814; 23:4JtPfHBEXn6nH7emnO6O68hIwyYUZQFP/sCQuNDA2?= =?us-ascii?Q?5w/zx9+mBQC0j5aWyWmuw72HUxKYgu/UY39IYdY5BelVOTGISWqOZ0Xam5DN?= =?us-ascii?Q?1jq0pN7AAWLjZg8ZouQ0f+qIrcBJr0vCEOsTAC4Qjie3+COCmi73HZmwGx8P?= =?us-ascii?Q?Pi3zROk3wx3wXpG626PoYV4phy8lbAXkZQZgWe3CFeErC3pIRMnP6l0Kpj3Y?= =?us-ascii?Q?DQEnCyVGLnvShOcJRO8P+yvOnBKGJO4EGh6gjmtJDaQB/2xTYdYCk5ALBq3m?= =?us-ascii?Q?EhUqvqFgFpkhrG3CdJ6H4P7orxPgqZXPfFXTAtU3Leta3s9Vpy9rRxlUJcJZ?= =?us-ascii?Q?3VpQQXetDvOEsL3x++Yc/2MO2/TRVwUkfv/aKUkZrhQ7svsV1K1aL2/+pwb7?= =?us-ascii?Q?UugKGPijVnFijFR66zyOJYmyk2oNqetw7mTAYV59htQm0WVB0VHkGvkK7RO1?= =?us-ascii?Q?qetkDsFMriu10vikYu/uEApffWhxJujLK5X3JMgpLIx/UEJTYKR/D/u/ktUi?= =?us-ascii?Q?wVrfQw85irKxd310UYUORhdOUiYKbZCbDFDevwsH4R5ZuB3sw5GYrJEyOY4+?= =?us-ascii?Q?2nN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p96O3t9gfZ6D2Grq6AvzCcgsbowm126TRnaicZcHUE6l50unuNF7JALwCWnRvXbyhPCJ0naIR2LvPrRc=; 5:GonN+N/fB4zr54qmdMssYiq9mJJJPuqeKVHwGeB1/ffxriuGmp6papxKd/RPo7MgQ6imKiupY9TLJOJGjsQ+ispIdyiVVnHz66k6tb8OPF/qNXtzxcPb1AH/gxeN6GYXRge3RsKRVJaDi+sJEO1D4jrGDWNDeZ5LWkmSYeDkjKU=; 24:MQrUTlViM3qTpnpSMMym35sEpPwpGOM2vGUZVgxcUv4OVlsFXi6Ozn+6rRAsuKnQcQcu1ra0ktpqrXbND5gKl15Cwpgd25skHs4tE9Xkipo=; 7:8wxgtxSz1Dqg4nX54HWt3z072weKqszo7BTIIKn8ojLremA53C2VvygGvyZDpMa8dTwsmDGDZdXUZKwPqsc8igP8qZERU9dZgvuFj16y4JDtLLyRvD3FvytIBjfKZvbvwJb35HCLjmqDhS/+h4KZeMXDqsG1NDUXr6X1cc3r8tWLVBgHm5wxNM63QFLL0HkqM0WsLa5r1hxXeMSBq0tUEvKW2iZ6j8ZcKLrzhYtu4nOUR6xQ4VeawdtyIsQ4EMAl SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: impinj.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2017 18:42:15.1035 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c824fa1-0103-4568-7561-08d5254619af X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 6de70f0f-7357-4529-a415-d8cbb7e93e5e X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR06MB2814 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In commit 974488e4ce1e ("spi: imx: Fix failure path leak on GPIO request error"), spi_bitbang_start() was moved later in the probe sequence. But this doesn't work, as spi_bitbang_start() has to be called before requesting GPIOs because the GPIO data in the spi master is populated when the master is registed, and that doesn't happen until spi_bitbang_start() is called. The default only works if one uses one CS. So add a failure path call to spi_bitbang_stop() to fix the leak. CC: Shawn Guo CC: Sascha Hauer CC: Fabio Estevam CC: Mark Brown CC: Oleksij Rempel Signed-off-by: Trent Piepho Reviewed-by: Oleksij Rempel --- drivers/spi/spi-imx.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 5ddd32ba2521..301cdb721bad 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -1613,6 +1613,11 @@ static int spi_imx_probe(struct platform_device *pdev) spi_imx->devtype_data->intctrl(spi_imx, 0); master->dev.of_node = pdev->dev.of_node; + ret = spi_bitbang_start(&spi_imx->bitbang); + if (ret) { + dev_err(&pdev->dev, "bitbang start failed with %d\n", ret); + goto out_clk_put; + } if (!spi_imx->slave_mode) { if (!master->cs_gpios) { @@ -1631,23 +1636,19 @@ static int spi_imx_probe(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "Can't get CS GPIO %i\n", master->cs_gpios[i]); - goto out_clk_put; + goto out_spi_bitbang; } } } - ret = spi_bitbang_start(&spi_imx->bitbang); - if (ret) { - dev_err(&pdev->dev, "bitbang start failed with %d\n", ret); - goto out_clk_put; - } - dev_info(&pdev->dev, "probed\n"); clk_disable(spi_imx->clk_ipg); clk_disable(spi_imx->clk_per); return ret; +out_spi_bitbang: + spi_bitbang_stop(&spi_imx->bitbang); out_clk_put: clk_disable_unprepare(spi_imx->clk_ipg); out_put_per: