From patchwork Fri Oct 27 01:08:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trent Piepho X-Patchwork-Id: 10028943 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 259E7602D6 for ; Fri, 27 Oct 2017 01:11:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1518B28E5D for ; Fri, 27 Oct 2017 01:11:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0904D28E8C; Fri, 27 Oct 2017 01:11:12 +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=-4.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 667E528E5D for ; Fri, 27 Oct 2017 01:11:11 +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:References:In-Reply-To: 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: List-Owner; bh=u56x9iregvV1yRCsZ2EfeM8XB9Xmp9h34T1+gWl90Us=; b=JJVYSFS4LUlo9/ FRuI78wxAIQEyjKSuWAFB4kBeBnSU0YkBYF8SmkjehhbhDNtVIGO8/fTaCJutPEyErCqfoqqAG+z4 9rj0xOLKjmkWB0RmqjyaXpm32dIASPWk7M9E1MF4aKTi0BkgGP8HLrcxQfrBWv+qnC26pxiVCgbnJ DihSs+706iqxU+04WudMdn5EfrbX8IC5Lh42JGtcjePr8Q08YtOtAND0EOhlAzvgLd94FHv1lutIk wHT9EhUHDMsv8li0XscHntstbDhuozkkayqZq3oqy1lVeo+4ECGYhCoYJVzlqhVroDVD/N9b9VGzR i40DEyagYBenqa48zdWg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e7tAr-0007M0-1v; Fri, 27 Oct 2017 01:11:01 +0000 Received: from mail-by2nam03on0106.outbound.protection.outlook.com ([104.47.42.106] helo=NAM03-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e7t9p-0005Um-Vm for linux-arm-kernel@lists.infradead.org; Fri, 27 Oct 2017 01:10:04 +0000 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=I/e/AhkeqxONZBQqGCrD/4rxRnt01xphI4jJCHZGVuI=; b=G1Op9jHvfwxP+sOsDyQKx08kQE8/UMUbGWEfTGbNaEteg5wLHxcna3fSUCwtN3GC9rF7LLToh9AaceTXRFaVrmsjFa6CDtVnHVwag2Kxsn8nl+4U2EnKfhOk1HrHVNGcCPvl9iJ2AYehJlIEONcrAfmhCB4zfsSzZEHXYKH3biI= Received: from impinj.com (216.243.31.162) by CY4PR06MB2805.namprd06.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.178.6; Fri, 27 Oct 2017 01:09:23 +0000 From: Trent Piepho To: linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org Subject: [PATCH v2 2/4] spi: imx: Fix failure path leak on GPIO request error Date: Thu, 26 Oct 2017 18:08:39 -0700 Message-Id: <20171027010841.28624-3-tpiepho@impinj.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171027010841.28624-1-tpiepho@impinj.com> References: <20171027010841.28624-1-tpiepho@impinj.com> MIME-Version: 1.0 X-Originating-IP: [216.243.31.162] X-ClientProxiedBy: MWHPR14CA0045.namprd14.prod.outlook.com (10.171.142.159) To CY4PR06MB2805.namprd06.prod.outlook.com (10.175.117.149) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cdd6f773-d316-4a0a-4863-08d51cd75c69 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(2017052603238); SRVR:CY4PR06MB2805; X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2805; 3:0yW6fV3MZGe1/IlrNufm91lya/66wCm9CAAk7hBxq7K5pyGY1W/lyixshEGPn0G95kvwpKDc9eoHcQYDr5NbN/pvT8fnPdahrhxOUdiaL0QQN4vbrGJ5QzwXNOnSNgmaYy+HFbiJALwyRUJZearCauxUQPyxVt6cgsgFCmfPDE5R/uVHkRvoTzE12bHfEctK/q18iv5hrNM+DsK8UpwEbLXVITlC6OF/qX4ejYtumAgaxM9EGG+DeICarn61FOH6; 25:rV3G7Jm27PO7tN4eFl81uuTkRmMChp0pvX11TVNBsPpcfPLsiQEO077EUQUuAspnkPU95d1w3V8TSqGqt5Q9kosAtREiurscOCV4aAR0gTA4PxNA/cCz1mcfW/OcozCdjbT7YdKH+Ggsoz/4guRQGtoXeOLkrQDHchuJ2kInTp+Yuc3kgZfcNbEWhpih9eeMHMupghOf4BotOSE2CMuxZ2Yoj2VAXnZjLsiRHS9ZbGU0OYRjt+Tev6NH+E2GFNAHy2cU7Dw+SCijSGozI5o/kpIjkqb8wUS/QUDpkbYnmvj3YKEy8b+s4RY8U8Osrq9xR51KK7D7RUjfZLteHMDW5Q==; 31:lv9GiSwq498gGL7DNQR4KliP2KzPw/l4cUekB+iAawncOjVXPrcwx/Xri+vq0MryBX2zXS0Fu7tMh2OSodU7kOUudiBwaS2nzHEOkzs9OshbbWBLqorsqHz8djpYmsY6KehnpyQLRuEw4gKozn68l8LvPKdanPj9PFDEgJKvAaRbgmt4Em8isSbFrErP7t6OnOc93g0sr5fPL0yfGC2Y8IpvyHcmiBSu6Sv88o9QuSQ= X-MS-TrafficTypeDiagnostic: CY4PR06MB2805: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=tpiepho@impinj.com; X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2805; 20:gqxN1aGf1rGL4adyYLoVqZdE9ohkMH5WErE6E4ZR3veYL7ujoxY3e7lbkYJF77LOvcN26U60cuL8FG7qXCEOLBL5a80hA4sAuGdPlKsrcpyRt23YJc3APpt7NPdNzlLvz4VqpniAsH+EVL0LmmJcVlnsWyTjaJGAcnvtsxeOozVVhMazn36Js516TzduTe5yj/pvVALZ9kblq5wdS6sl7cfVrjEv0rOYv8ZLv/w+OlyONP6iTRqwCWObF0JTeYR3zpoj/n58ESjJQlKQ9qzE+esQV0+kXJz9n+dNfxg+wyiqcDytlT5lEZ9+TA0pYpyq2nPB0yY81KqsjX7parumHL4g6jldEg+DcI+CQ+0/bg15o284Cj8bsOktK8y/92Z1LIfObU69rpVqq4o9bndxgl3VLWC0MxBuWOU2QcnwL3TELhsKFIDatYRhw/71q+urEZnrC3FIXqIRkrvwlTV8yGAh/bn4Jo8nT8X599TQBmJFSqnbkIFaM/jh/AUKr1mU; 4:yx9+67EsJYghNN5te8Wzz0J6yob5HlKcWfwwnA9hHXC93rq+b0a/BuspVwjRw3KOOl9VwIj0D2yfpdOhM1DqaomRIE+p0q5YyA/nvyAGtG/Ru3pODylmoIC9yEdJwWR8nwAspT4uEV0NiIOm/1KBhgd2L+rLHBfHu7Z3mb8NmthPNALzUi62Zus9+ANujo9PUKkMWm0bkGD/II4AN1UVgw1D94vDdS4ExL7TNA1U1R4S3tfqhF6uYWXTItCjUgsNSuiCz6HedqJh/JC5d7ts5TyiTAkxt0qiaHqC44wJUUv8S40HlhiirqRz/qU1L3tE 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)(5005006)(8121501046)(10201501046)(3231020)(93006095)(93001095)(3002001)(100000703101)(100105400095)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123560025)(20161123562025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY4PR06MB2805; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY4PR06MB2805; X-Forefront-PRVS: 0473A03F3F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(346002)(376002)(39830400002)(189002)(199003)(25786009)(53936002)(3846002)(189998001)(21086003)(101416001)(50986999)(8936002)(6116002)(33646002)(1076002)(305945005)(7736002)(97736004)(2950100002)(8656006)(5660300001)(16586007)(16526018)(54906003)(4326008)(6666003)(69596002)(478600001)(68736007)(36756003)(5003940100001)(86362001)(316002)(81156014)(2906002)(50226002)(81166006)(106356001)(8676002)(105586002)(76176999)(55016002)(48376002)(50466002)(47776003)(66066001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR06MB2805; H:impinj.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; CY4PR06MB2805; 23:6gdrwxE4i4rkGh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B1dPFbM/SD5nym1AJYtPLztbCAVy3lRbdLLXo7UBj/gOkIhbQMSwpl34Ate8HuBvr2HbZM07NYw7KVjGejxOEUoAByb1qrEy+Zza4ckuwtbVJuHf2z6e5VhBSKLPn478otOqgoJt5Lsj/kylynTfctcIU0pO97aarUw2JYx5L9DQZhdvCCJnHEm205HA/UR1mR4e77hTgNw SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: impinj.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2017 01:09:23.4243 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cdd6f773-d316-4a0a-4863-08d51cd75c69 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 6de70f0f-7357-4529-a415-d8cbb7e93e5e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR06MB2805 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171026_180959_024475_946082B6 X-CRM114-Status: GOOD ( 11.43 ) 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: Fabio Estevam , Mark Brown , Shawn Guo , Sascha Hauer , Trent Piepho 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 If the code that requests any chip select GPIOs fails, the cleanup of spi_bitbang_start() by calling spi_bitbang_stop() is not done. Fix this by moving spi_bitbang_start() to after the code that requets GPIOs. The GPIOs are dev managed and don't need explicit cleanup. Since spi_bitbang_start() is now the last operation, it doesn't need to be cleaned up in the failure path. CC: Shawn Guo CC: Sascha Hauer CC: Fabio Estevam CC: Mark Brown Reviewed-by: Oleksij Rempel Signed-off-by: Trent Piepho --- drivers/spi/spi-imx.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 07e6250f2dad..fea46cbf458a 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -1451,11 +1451,6 @@ 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; - } /* Request GPIO CS lines, if any */ if (master->cs_gpios) { @@ -1473,6 +1468,12 @@ static int spi_imx_probe(struct platform_device *pdev) } } + 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);