From patchwork Tue Oct 31 19:49:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trent Piepho X-Patchwork-Id: 10035303 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 20F99602B5 for ; Tue, 31 Oct 2017 19:51:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1191328AFC for ; Tue, 31 Oct 2017 19:51:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EEFF928B00; Tue, 31 Oct 2017 19:51:09 +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 647F528B00 for ; Tue, 31 Oct 2017 19:51:09 +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=/dZUeWC8Vvxmk5cnlZ2Wf2nQphb4M7wkY67gghqOHfc=; b=P4lfuVzofQwx5Z mnMQDWnxTUms5OAVBNxy00jlJBSg6Uw2pXcvu0wxWtizKDYAzN45jtzY3Oc6HgwRBbnWzOqxpjGhN DRCdNwZxfqTDjRGUE+Br9B49+W3CfcUr6P1uCAv0BlQbsf/fRa4m0fehQYc07CdT352jfVwpyRkEc lDYA+dGLQ4d0PQ0QgEPu413GAplTlXNExvvgcZ8zYtx546+6/2YDpnwz9aXeTlIPAsGNwAjx0fvXk sz6QSTO3QI67SOvmR83kXTa6u7rtp9qVCqfiC7mU5tREW+rI2g0E+QNGSBxCM7s3k5Kxc5ft6FulT 8d60xhnFejIfHUVJMt0A==; 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 1e9cZ2-0008Ml-89; Tue, 31 Oct 2017 19:51:08 +0000 Received: from mail-by2nam03on0725.outbound.protection.outlook.com ([2a01:111:f400:fe4a::725] helo=NAM03-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e9cY2-0006OG-EN for linux-arm-kernel@lists.infradead.org; Tue, 31 Oct 2017 19:50:08 +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=n7Ao6RPCR94Buplg4BPG00/U/xV7MrPLleo7CgQTrU0=; b=OmHH7IXJsxelMv5FTfYfwyEdCWFgx/hQuqyXaO8ih/rpsHFG71IT2W7Om/oGfffzwaWS+Uote9s25FG8FeUJbHc2v0cE/7GyCgU50UElcGO1vKOPFdSRa4SVOIeX5Lba5KImLzLnxIYFt6JGPlQ1yysGZK73xRgGnnsc8OZGhVQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=tpiepho@impinj.com; Received: from impinj.com (216.243.31.162) by CY4PR06MB2808.namprd06.prod.outlook.com (10.175.118.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.178.6; Tue, 31 Oct 2017 19:49:32 +0000 From: Trent Piepho To: linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 2/4] spi: imx: Fix failure path leak on GPIO request error Date: Tue, 31 Oct 2017 12:49:05 -0700 Message-Id: <20171031194907.29108-3-tpiepho@impinj.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171031194907.29108-1-tpiepho@impinj.com> References: <20171031194907.29108-1-tpiepho@impinj.com> MIME-Version: 1.0 X-Originating-IP: [216.243.31.162] X-ClientProxiedBy: MWHPR22CA0020.namprd22.prod.outlook.com (10.172.163.158) To CY4PR06MB2808.namprd06.prod.outlook.com (10.175.118.8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18853cd1-4713-496d-7d4f-08d52098821d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(2017052603238); SRVR:CY4PR06MB2808; X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2808; 3:brWr2sWUFXMw9fuyXJSoVMC4c0jcscodctYE5cSfbNTTsC1Lc8yonL3pHtl8ADO0IQjLHRQbkc3A7ekh+K0brYhyYMz3HVyFwO6Jga9sg+FNJekrPQij/OzJqeWesUvbFrp0gpTguC/9qYew8Gf+LDXJusvF611H4wJxkNEAGVpkNq1WOvFTszwlNs81u9aW3dPUEVd6og1okkPSuXWUD4mdyvRWd7sUoQ1GsS2f9+REeT4RcKMPmEnGBHJmJEGx; 25:Pd9zRuiePerDLFGVuXWtdbmWzdJ5RNIwa5SnSTTnos31gixy0crVe/q/OCzeBQ3pddhQMGuCvPY0rvbZwNrpBknhet55Hh+3uYBC+BY7/jbBz33cNjzShasGKNOC/O3uAVKBSh2jY210XewTG8jqDa3uMMJAkZTyz+BCPuAy0GilTipk3YWLiv4XuYEwa3cuDJPTTileA1bP1kEYcOfu8TFGLyXHSNaa+HhxJ34sldFDT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Ltq8FYnQW/DH1lJ/7KrDABcrAnJqlnu8fsKiNSI/3h0FjP84YtXVdESVVEXra9qUdobGZFRiNuIdbgXf4xYkee3V3vPEWCMgi2uqF21of2r/8NA7dkKXvkXSpb1IkWT1sgiA21J9+bFfFmJyEPD3pExdhhohD2/0ZxO8hJvfWsMZHe0IW2YpYr3x21x 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)(3002001)(10201501046)(93006095)(93001095)(3231020)(100000703101)(100105400095)(6041248)(20161123560025)(20161123555025)(20161123562025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY4PR06MB2808; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY4PR06MB2808; X-Forefront-PRVS: 04772EA191 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(376002)(346002)(39830400002)(189002)(199003)(97736004)(53936002)(478600001)(86362001)(575784001)(76176999)(101416001)(50466002)(50986999)(48376002)(69596002)(1076002)(25786009)(66066001)(81166006)(106356001)(8676002)(33646002)(105586002)(6116002)(3846002)(4326008)(36756003)(81156014)(2906002)(189998001)(8936002)(55016002)(68736007)(50226002)(2950100002)(16526018)(21086003)(305945005)(5660300001)(16586007)(47776003)(316002)(6666003)(54906003)(5003940100001)(7736002)(8656006); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR06MB2808; 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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vsfQNGEH14+g2o=; 7:FORD5esTFBdFJyP99ssLEipCJXc1MfYjSl+bexZHKHA0yTS9lg7/xMPrYBi1lTdtMHJyo9QKaBl/yHUTSrkKP9f7g9E9a5yapgoul1lfdneo8hY7T9YPQIlMXQzoTiIyiZ2/KcUliDer6Kda0eUw762XPveUxBaZqIbsbY+38JKESeFTFv+l2+6BOTqADDHMqLZwoVuSjIN8ApvNVIpKNYxoCLNFHJvrrQ7zHPEGsWuJUTqQKSNwY0WXMl53rDJ1 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: impinj.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2017 19:49:32.7256 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 18853cd1-4713-496d-7d4f-08d52098821d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 6de70f0f-7357-4529-a415-d8cbb7e93e5e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR06MB2808 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171031_125006_673198_E590A871 X-CRM114-Status: UNSURE ( 9.95 ) X-CRM114-Notice: Please train this message. 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: Oleksij Rempel , Mark Brown , Sascha Hauer , Fabio Estevam , Shawn Guo , 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. Add this to the failure path. Note that 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. CC: Shawn Guo CC: Sascha Hauer CC: Fabio Estevam CC: Mark Brown CC: Oleksij Rempel Signed-off-by: Trent Piepho --- drivers/spi/spi-imx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 76bf0e4fc2c7..ad54f8258513 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -1638,7 +1638,7 @@ 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; } } } @@ -1649,6 +1649,8 @@ static int spi_imx_probe(struct platform_device *pdev) 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: