From patchwork Fri Oct 13 19:54:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trent Piepho X-Patchwork-Id: 10005821 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 001F860230 for ; Fri, 13 Oct 2017 19:54:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E76012915D for ; Fri, 13 Oct 2017 19:54:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC3E129160; Fri, 13 Oct 2017 19:54:45 +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 7E04B2915D for ; Fri, 13 Oct 2017 19:54:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752994AbdJMTyo (ORCPT ); Fri, 13 Oct 2017 15:54:44 -0400 Received: from mail-by2nam03on0092.outbound.protection.outlook.com ([104.47.42.92]:45376 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752876AbdJMTyn (ORCPT ); Fri, 13 Oct 2017 15:54:43 -0400 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=J8Z4WMVk680VavP4eCFhJkzaE3OIrYkI3XLxNYNhP68=; b=g4Mgd9hirPjWifta3YIsL+7pgTRaYO3kwkgvJZb5v+nxHZkg2Qi+ceoVnFb0CcX90IOokS7irfmBNkokrCuMg6aKz+n3eLmZtFrSet+1/FgyzxekwmEa5fNfDjFYtURZQlFS/VyJ4FGymfyL95fLPRHfRrIatF1eLSzrHdY6pSQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=tpiepho@impinj.com; Received: from impinj.com (216.243.31.162) by BN6PR06MB2803.namprd06.prod.outlook.com (10.175.127.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Fri, 13 Oct 2017 19:54:41 +0000 From: Trent Piepho To: linux-spi , linux-arm-kernel Cc: Shawn Guo , Sascha Hauer , Fabio Estevam , Greg Ungerer , Trent Piepho Subject: [PATCH 2/4] spi: imx: Fix failure path leak on GPIO request error Date: Fri, 13 Oct 2017 12:54:08 -0700 Message-Id: <20171013195410.30767-2-tpiepho@impinj.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171013195410.30767-1-tpiepho@impinj.com> References: <20171013195410.30767-1-tpiepho@impinj.com> MIME-Version: 1.0 X-Originating-IP: [216.243.31.162] X-ClientProxiedBy: MWHPR21CA0064.namprd21.prod.outlook.com (10.172.93.154) To BN6PR06MB2803.namprd06.prod.outlook.com (10.175.127.21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dc72ae7e-b12f-4c87-c2b8-08d512743eff X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:BN6PR06MB2803; X-Microsoft-Exchange-Diagnostics: 1; BN6PR06MB2803; 3:Oq5MXeI1enX8kx0vDL8xFeLhxaciMh4tnsq3Q8XJn1yA+h9ojCurCsuQ10oZT+7WBn2sG9sENXRWgMzdemHyURl45uq5doihsv2sg2kWolTQU+VveFAmu0iO72RI1QzOXlNw7fhm0lS6KyNjxCvc6emEf1hLy2vs2Rx7tgFYBVWF6QQR49tTvcINqxJ/A7QVIaDtuBANWDlnh5IHkzgC78oj423AtwBzpN5V89PEnRKFoDU42ZlVLYQsZapARCX8; 25:nuxrAhi70RRAW2/wzXsaLJrygRcFUjzzuAajOH7yzNDkGXlYmokibOgM3uSjLMqE4Omz/iQ6D8eNphdlTQcdignslFp//rtVE9a/7OyIHnmxvJSnQWOxX7hZZwYO8Bn1OE+pe7aShFbNrbomgS7VWYzXHXL82/35oS0zRK9z5qfbBpum9ZhElBPEykMa9ScFjIuejdmxohcbusFFraK+q59ijxKiAu7MvnAdTvNU3kP1cyoZv4Savj+kLXjHGTM9nD4bZ0Z79Qrudrs48TOaHCd93v86hIiovJtQ8RuxG7rVLM0S4hv043xk7J/lRzDS/UbSF7jW1519MB/FXVH1cw==; 31:xc+2zx4XBdtJZadPl0qxcS1GidZ8eOlsr2Q980+1NKmqIBbsHBZ46eT4YFTOXRv2fmABmjnMSfIQpUZ9HZY5ebnOp/PkIxxd1gykueT54kmfWUXliAlAG3k/fGK2P7EC1Zs9+F2QICAuzRTOC3L6pvsSptyN7PoUzT3DRdSo6QafxR9t/Gieli2RKaKGOk9wXYQQiHQasQYJwklsg4Gl7eiuNM/1nblrmJHwG9WPcoo= X-MS-TrafficTypeDiagnostic: BN6PR06MB2803: X-Microsoft-Exchange-Diagnostics: 1; BN6PR06MB2803; 20:hqwXoGfJELTQV3jL3IhryzFe/UnQmz1P3eViovuzmqXTTepigMUJ84jf/WWCJ8DIyU7juP0WlJkzEDsBkDtdy319LjPkqZR/cTt/KErBlauENFNOyQXaGK8D8o46S/GZf1uZgMDoqM8wEnaHfNtXrLeTOCKnjvL12ErayEavRhP9YkRF85WE6xd65tPOGCzu7lRjYMlMkthLePPFNluA+vDpKjbkMJcd+OSrkP8QeMATGsLHddmauuFdsodITuqYwS+KfSLaDk7gk51LQy3FBw5kWT/eEiLB95FWKKIRJCVKsfr8kduUjDPXrd42wtfCcRb07gsX95brv9hPdE9Hw32ixZ8lUYM50NE6HEY8UovzqvoLyFYdW6NPwaEBV85solrOvdyA/2LGCBy65xVnLZh+BJxkFIO+BRhlERy9WjiHVlN59jzoqakb4exGLpf8wnpNLJtaDdqtintrg8esVv/ihCM2OdFL25EItu/G9OazI8eKdSY2FqecR/WSPHhq; 4:ULcIFz364AcI6MtxgWHSRGqH8SudGnvGpuuRKYdqQfaxnYLFWY44BAumr7NP1HoBf40bp1fWqSC0j3Ab9zSe+TQwWEneEOZVPr6MguXJbmsBZifHpfEDkhgUMzW0T35oqPPWgpRTF7TIgYeQLIvWOw6XWaizrRPUQ4QrQf8XXg1NZ2ZZFSI0wPlEU/8/Z7k8eBSLjTWFKDUU5B78xOM/ANzaaSxZr9MdZVGYPkde2vqVZu/KsMNWATEjvDoHxeLq X-Exchange-Antispam-Report-Test: UriScan:; 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)(100000703101)(100105400095)(3002001)(93006095)(93001095)(10201501046)(6041248)(20161123560025)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR06MB2803; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR06MB2803; X-Forefront-PRVS: 04599F3534 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(346002)(39830400002)(376002)(199003)(189002)(47776003)(6666003)(107886003)(8656003)(4326008)(53936002)(21086003)(68736007)(66066001)(2906002)(5003940100001)(2950100002)(3846002)(1076002)(69596002)(33646002)(6116002)(8676002)(105586002)(55016002)(189998001)(106356001)(48376002)(478600001)(50466002)(110136005)(50986999)(97736004)(76176999)(5660300001)(54906003)(50226002)(16586007)(81166006)(8936002)(316002)(305945005)(16526018)(86362001)(7736002)(25786009)(101416001)(36756003)(81156014); DIR:OUT; SFP:1102; SCL:1; SRVR:BN6PR06MB2803; 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; BN6PR06MB2803; 23:gvvMEs+k2RAPRhuZVqIkOv/M6hsoQDF1PHJ0Sz8Tq?= =?us-ascii?Q?rrepeOuQMJKhxVC3pj412MBCL6+/EqysaLCh8jfFqJ29g9OImn4JzpOIY8TS?= =?us-ascii?Q?5X9exPtsWhzVLvuu+myYYwtR6cX9DCaV2+2QlTLxpQTGJuYuMU8AnCgrtjUF?= =?us-ascii?Q?dP407dOy/r8WmH7o9sG+RHUy73Hbg9SeSiQzqZ+gHXD2o8uQ7jvfAsdc0lRt?= =?us-ascii?Q?5N/eqgq6x4ah25A/AJLFuOo7bBad8enk9yo7/UlDyB5KVfrzr8P2+Zpmm4DD?= =?us-ascii?Q?4xwJGPrCw7XLJ4WSBxG6k7DZKoJ5lkXcNW/40vHmRbUwzZC9+pJjq6Ynn54X?= =?us-ascii?Q?EwWwi5qHZjYXP7EKvzRgDMJLVOST65ndwAK1dpgkSahQ0gO1DiACOZsR/l+f?= =?us-ascii?Q?/1B1oGm3RP9teYvnRq+wHN5xskq8BPtpgU6JkEBLjv0zLz4wN1nSzZGanLHV?= =?us-ascii?Q?xZJsSbBJNn+xXLKpl5pkD8CCCsG6lT9E6NzCq4qskdfamWJ3e7dSLbl4cM1V?= =?us-ascii?Q?KFtZxuNptOWa7sX4lMf+B6vxK2HRHmFmJpY5hJ2c8w4KeTYxubPRWKa7vvpx?= =?us-ascii?Q?lR/HOb6iu9hujRusl6xb0rZ+BOJ98erQhykLKa+svYoevdG52kiIy2ZSkfPP?= =?us-ascii?Q?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; 5:vOgicA5mDumG/M/5dEmVd99hu/j7dID3Ns4j+UisjKmpuSrEBJ+KRkatHwHis1TiSD2gCoWQrxnnSB/KbtSA5RJgesT64y+kug6SKPiw1wnf1tJ+gh1uSWq2T7C27B13VJktLvqIhfUeP8XBQfjKVN5xPDAwIy+GVPWGUIjp9jc=; 24:NxE3tL49+8FsSEQ4Uujr2H1BAIz/01E3YnxUIiV3fgkT4lx1Y6ovXP8siHE4YMPOWEoXKhAh7fQRyPE7Kq7lEJqFORirdyQAQDuzjr0epaA=; 7:QU+29gqQIMRpOoi2WNtxZmVwz9lGbLkRDFebwC9MuP7n5cNUw3TXQgQYCaJldqjWHao6VbOpSRBWpHErn2E07SbbsvZRxZ5ClVwZQngNmso1yUJMDo2q5O1pZo5mCQ/o3gMLKzpZZrJShOVFlvmdtE/QSxZgGmn24X+kErdKcW3At44NrVZzF4jAX90NxYsmgTsYwYMZw+1sLrTmcN9xaFly8gRrAjgK0ssyRBe/y60= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: impinj.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2017 19:54:41.8217 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 6de70f0f-7357-4529-a415-d8cbb7e93e5e X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR06MB2803 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 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. Signed-off-by: Trent Piepho Reviewed-by: Oleksij Rempel --- 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);