Received: by 10.213.65.68 with SMTP id h4csp487884imn; Fri, 16 Mar 2018 09:14:22 -0700 (PDT) X-Google-Smtp-Source: AG47ELvSpqqMFPCuaonqqLXTI1Uen7flXgxAu24dgzDOe0XTg0vLRDYJjuiliYXwlJg6HroVl60u X-Received: by 2002:a17:902:1665:: with SMTP id g92-v6mr2672708plg.195.1521216862488; Fri, 16 Mar 2018 09:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521216862; cv=none; d=google.com; s=arc-20160816; b=t/oSOuy0iJucjjHK3IElMhQiJAlMHFAdvAbOmIGvHjlfZlM6q03YZIs7juFuPjfdRL uMfXDOpXclygWURSXCS2d2wGPBHwgDqt4bB9W1gOlFhSNodlFdr1YX0/bjAnfxZ+ZBsK akiheOxxOhkXfBLLxIYvCb6wTj11jZb+MZk75J9yG2JwBtQ8VKIlT7kXXtyFSzO0d+F2 ZGXYi7O4sW70E0cpY9NtouFPkFBODIUSrlgArtErlSKVyRRkCVE2DJ2lnmjL6hGLyk1C o3SEXiar0RsDjogMnT6c96TpRFRAMdHBqJ/SREVng4ntyB46ju0nEuUrhUfYWtIDuNx+ 81hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=QHaTIE4Em53HfsHXhokMN0CTxnGd/7KAyWGru1lRelA=; b=q000Idf5JVbP7htlVHAoEBY/ehXntD6Lj8h/85sifyveWXk9wd0KrU146yB5YZVfNy m8ZKI8I/vjh4k02KIdjoYav+Oh/8s3ScZuqxeWPHcX0lCGgagS6VaVjzOuL5GWqAlTF1 Z39E0ez1pNU/r8z7BjpmfWT5Xg6g2WYSUUiL2U468DO8+hMceFOE28ZR/5NwOJajkybm 5LSspXoxfX/tB2q8eQ+ngS8cvHb42Bb1QG2gop2TbA8nNmTnmBrbdOXPh8qI6Id26zVz V5uLI1I1Eeu7b6lS2XSjT4/hTtvNKNV18wFM71fJ1jWsXv1BJ34x25xvkDuECN7RUZqr nKiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m10si5205883pgs.236.2018.03.16.09.14.08; Fri, 16 Mar 2018 09:14:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965040AbeCPPkX (ORCPT + 99 others); Fri, 16 Mar 2018 11:40:23 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43526 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964989AbeCPPkS (ORCPT ); Fri, 16 Mar 2018 11:40:18 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 29911D4D; Fri, 16 Mar 2018 15:40:18 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shawn Guo , Sascha Hauer , Fabio Estevam , Mark Brown , Oleksij Rempel , Trent Piepho , Sasha Levin Subject: [PATCH 4.15 029/128] spi: imx: Fix failure path leak on GPIO request error correctly Date: Fri, 16 Mar 2018 16:22:50 +0100 Message-Id: <20180316152337.986897158@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152336.199007505@linuxfoundation.org> References: <20180316152336.199007505@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Trent Piepho [ Upstream commit 8197f489f4c4398391746a377c10501076b05168 ] 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 Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-imx.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 40390d31a93b..6f57592a7f95 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -1622,6 +1622,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; + } /* Request GPIO CS lines, if any */ if (!spi_imx->slave_mode && master->cs_gpios) { @@ -1640,12 +1645,6 @@ 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); -- 2.16.2