Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9097030pxu; Mon, 28 Dec 2020 06:33:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJw9w/LZL0K7Kw47ad6RgMRVZa7+AE07ZzY53EPFAM8ijSlUBTQZgGqCEJzRpH1RiCPz7FFp X-Received: by 2002:a17:907:961e:: with SMTP id gb30mr40135576ejc.197.1609166038782; Mon, 28 Dec 2020 06:33:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609166038; cv=none; d=google.com; s=arc-20160816; b=lv+TssXp+fs0y7E+H8gV6i0EV1X68U3eBeuKM/+EYbt7KvHW7lnrr4ICW9BtOjF0Ye tr2wZbAJXGyESfy8pvzmi0Ri+Ra9y2rBdeh8rP+xOPbt8ZDBHYtCEXqJ1ZFBummZosXE SMiiD0MezVGeB0tyB458vyCQ5lckK1ieDSwXQcUP/J+xr+KxklMGxvh/LqwQFgxE9xzP etGB+TFya7AF28k8RqxgBTl4IF/BLQ8ghknMUF7CSXvOTvyHBdfM7J3/5o/Bnas7AXfl 4LofTp88OWMgiopvjUcCixe+FTTnTmFbJAxJArPt0U8ocE2I3lc7C6d0zXTp9dRbwGD/ 3+ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KHJWK+S/sHe9cNnCCBJlu9zibGkgZ6LgfxgTPKMNy5M=; b=gVUl2XF3NdQria/wqnWuWUd5m/wl8kywqoWPSjgiIx9D/ALXpr4bqU7Cs0qvKegw+h igiY5S3cHST/pLJ7kEo0LuNs1p4CO1kHyl5x1DKqWptG3FpzFOP/SIhUzUcvuTbdvDAU mtVntwvikOzPkrvaIA2kKLzcXkTpr21PwGSXiOT8t7rvnT0f75ckBrd1WbOgeFqAJnES j+For2Pmlh8LPpJzRpmKw10S2cbmfEPlkkq0HhT0FWUcqih5Sk7HmTyYVHowHCIJ6fg6 TBTQadbPx/u/b/dI/AAA9vPdRDQ9iKuVd/k1lbw3TlnvJ3RU/oYGC0dmASxSPk4jb9Tk idSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vbMY4lKI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si14920087ejb.78.2020.12.28.06.33.35; Mon, 28 Dec 2020 06:33:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vbMY4lKI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503646AbgL1OaT (ORCPT + 99 others); Mon, 28 Dec 2020 09:30:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:37894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503841AbgL1OaL (ORCPT ); Mon, 28 Dec 2020 09:30:11 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 19A2120739; Mon, 28 Dec 2020 14:29:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165795; bh=5CxXwJsHIVYiELt/5s2GbBgoikOIqhH7B9YSoH+EbJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vbMY4lKIG7aF1dgAy9BQBfKhjReqq7luIULCkSuAQHZILShz01xHYGaGCWyppvL2A QyqQeIC9A/WM5SOmgs/oT1QRdd2ub7oBmdItlj5s8XvX3MELOpoZEW8AJBwdCCZ251 N+EMV/Ju+DxUXwmoYYjjypx9syjsp0B514L8C2bM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Wunner , Masahisa Kojima , Mark Brown Subject: [PATCH 5.10 658/717] spi: synquacer: Disable clock in probe error path Date: Mon, 28 Dec 2020 13:50:56 +0100 Message-Id: <20201228125052.482933315@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lukas Wunner commit 8853b2503014aca5c793d2c7f0aabc990b32bdad upstream. If the calls to platform_get_irq() or devm_request_irq() fail on probe of the SynQuacer SPI driver, the clock "sspi->clk" is erroneously not unprepared and disabled. If the clock rate "master->max_speed_hz" cannot be determined, the same happens and in addition the spi_master struct is not freed. Fix it. Fixes: b0823ee35cf9 ("spi: Add spi driver for Socionext SynQuacer platform") Signed-off-by: Lukas Wunner Cc: # v5.3+ Cc: Masahisa Kojima Link: https://lore.kernel.org/r/232281df1ab91d8f0f553a62d5f97fc264ace4da.1604874488.git.lukas@wunner.de Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-synquacer.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) --- a/drivers/spi/spi-synquacer.c +++ b/drivers/spi/spi-synquacer.c @@ -657,7 +657,8 @@ static int synquacer_spi_probe(struct pl if (!master->max_speed_hz) { dev_err(&pdev->dev, "missing clock source\n"); - return -EINVAL; + ret = -EINVAL; + goto disable_clk; } master->min_speed_hz = master->max_speed_hz / 254; @@ -670,7 +671,7 @@ static int synquacer_spi_probe(struct pl rx_irq = platform_get_irq(pdev, 0); if (rx_irq <= 0) { ret = rx_irq; - goto put_spi; + goto disable_clk; } snprintf(sspi->rx_irq_name, SYNQUACER_HSSPI_IRQ_NAME_MAX, "%s-rx", dev_name(&pdev->dev)); @@ -678,13 +679,13 @@ static int synquacer_spi_probe(struct pl 0, sspi->rx_irq_name, sspi); if (ret) { dev_err(&pdev->dev, "request rx_irq failed (%d)\n", ret); - goto put_spi; + goto disable_clk; } tx_irq = platform_get_irq(pdev, 1); if (tx_irq <= 0) { ret = tx_irq; - goto put_spi; + goto disable_clk; } snprintf(sspi->tx_irq_name, SYNQUACER_HSSPI_IRQ_NAME_MAX, "%s-tx", dev_name(&pdev->dev)); @@ -692,7 +693,7 @@ static int synquacer_spi_probe(struct pl 0, sspi->tx_irq_name, sspi); if (ret) { dev_err(&pdev->dev, "request tx_irq failed (%d)\n", ret); - goto put_spi; + goto disable_clk; } master->dev.of_node = np; @@ -710,7 +711,7 @@ static int synquacer_spi_probe(struct pl ret = synquacer_spi_enable(master); if (ret) - goto fail_enable; + goto disable_clk; pm_runtime_set_active(sspi->dev); pm_runtime_enable(sspi->dev); @@ -723,7 +724,7 @@ static int synquacer_spi_probe(struct pl disable_pm: pm_runtime_disable(sspi->dev); -fail_enable: +disable_clk: clk_disable_unprepare(sspi->clk); put_spi: spi_master_put(master);