Received: by 10.223.176.46 with SMTP id f43csp2595887wra; Thu, 25 Jan 2018 12:18:03 -0800 (PST) X-Google-Smtp-Source: AH8x226UngpMm0lJCe4Xpn75Aa4nxIBiwovj6vk7nx8IzTWW9I6lOnc8psQZcuxvXqD771/TxZPS X-Received: by 2002:a17:902:67:: with SMTP id 94-v6mr12148558pla.183.1516911483234; Thu, 25 Jan 2018 12:18:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516911483; cv=none; d=google.com; s=arc-20160816; b=dyoHW8dVFzPFAAdAIV/pE3H9VKhaVI/qqzMRHNTJZEcgEMxhhXlyMKH/7rodTcLL23 wDixbdiN3UYUFzjWV2NVvFQBXx8gW1BABcfB9kFaWHdvXNMnW/DYpsjMCKlBB8wIaXx2 guX/ZQdnba8Ms8WH+xe8rQlf/yyspcmG9PvXMZ31jCOaN72MwQ10sTbTPz8C7SC3GMyg R1w1NHRi2ypyQRLP3OuxRwN2yw+IwQ6f/7QQ/uYjjX6a6fdh7QL0j2eLLvUi83y9qs1H qSUg2jIKEBRk6h9H1VKm8wqhTsGOnb5csOijoShZXuxDr/4TkEsB9AkkEzhJ+Xcobl5B L+EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:arc-authentication-results; bh=w46c8ULg00RewGgtL/VsA92FNd/6lgLnBcqtLWOFVeI=; b=Een9gOmcT4lRKxLRuVB3GHQQHCr/l3TcyEEKkAGcaT2mhOlwFTtG42VWxHnqIFEdcR ViCOqlGCcZ3m9+jfxYEwmCcolms44nTdsdyPUB52BTGFlbn6qxgFgsCy15PyOXWgyROR 3NojvZm9NBvj+J1r//TjCvf0JD5wkqVS6jB8pQQJDh8FD8BpijzeHwhbit5uCo43zZPI ATx71Py0A7xOm8R7Y0p3TSxiwzdC97jxno9rQIvpEYS09TvIcYnphefztupX3wcHBzBU lb8yUhsTFv0i42vVptYC3JlnWBQ0AGYh4aFte+3VaN7LolnkWpg/1FqqpZuvKSeKA8Of Vemg== 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 b12si1952295pga.371.2018.01.25.12.17.47; Thu, 25 Jan 2018 12:18:03 -0800 (PST) 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 S1751474AbeAYUQY convert rfc822-to-8bit (ORCPT + 99 others); Thu, 25 Jan 2018 15:16:24 -0500 Received: from smtp07.smtpout.orange.fr ([80.12.242.129]:37842 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751259AbeAYUQX (ORCPT ); Thu, 25 Jan 2018 15:16:23 -0500 Received: from linux.numericable.fr ([77.198.79.136]) by mwinf5d30 with ME id 2kGK1x0032wTeBR03kGKXi; Thu, 25 Jan 2018 21:16:20 +0100 X-ME-Helo: linux.numericable.fr X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 25 Jan 2018 21:16:20 +0100 X-ME-IP: 77.198.79.136 From: Christophe JAILLET To: broonie@kernel.org, gregory.clement@free-electrons.com Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] spi: orion: Fix a resource leak if the optional "axi" clk is deferred Date: Thu, 25 Jan 2018 21:16:17 +0100 Message-Id: <20180125201617.17099-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Antivirus: Avast (VPS 180125-6, 25/01/2018), Outbound message X-Antivirus-Status: Clean Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the optional "axi" clk is deferred, we still need to undo some initialisation. Espacially 'master' must be released. It will be reallocated the next time 'orion_spi_probe()' is called. Add a new label to clean what needs to be cleaned and rename another label to improve the names used. Fixes: 92ae112e477a ("spi: orion: Fix clock resource by adding an optional bus clock") Signed-off-by: Christophe JAILLET --- drivers/spi/spi-orion.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c index 482a0cf3b7aa..deca63e82ff6 100644 --- a/drivers/spi/spi-orion.c +++ b/drivers/spi/spi-orion.c @@ -638,8 +638,10 @@ static int orion_spi_probe(struct platform_device *pdev) /* The following clock is only used by some SoCs */ spi->axi_clk = devm_clk_get(&pdev->dev, "axi"); if (IS_ERR(spi->axi_clk) && - PTR_ERR(spi->axi_clk) == -EPROBE_DEFER) - return -EPROBE_DEFER; + PTR_ERR(spi->axi_clk) == -EPROBE_DEFER) { + status = -EPROBE_DEFER; + goto out_rel_clk; + } if (!IS_ERR(spi->axi_clk)) clk_prepare_enable(spi->axi_clk); @@ -667,7 +669,7 @@ static int orion_spi_probe(struct platform_device *pdev) spi->base = devm_ioremap_resource(&pdev->dev, r); if (IS_ERR(spi->base)) { status = PTR_ERR(spi->base); - goto out_rel_clk; + goto out_rel_axi_clk; } /* Scan all SPI devices of this controller for direct mapped devices */ @@ -705,7 +707,7 @@ static int orion_spi_probe(struct platform_device *pdev) PAGE_SIZE); if (!spi->direct_access[cs].vaddr) { status = -ENOMEM; - goto out_rel_clk; + goto out_rel_axi_clk; } spi->direct_access[cs].size = PAGE_SIZE; @@ -733,8 +735,9 @@ static int orion_spi_probe(struct platform_device *pdev) out_rel_pm: pm_runtime_disable(&pdev->dev); -out_rel_clk: +out_rel_axi_clk: clk_disable_unprepare(spi->axi_clk); +out_rel_clk: clk_disable_unprepare(spi->clk); out: spi_master_put(master); -- 2.14.1 --- L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast. https://www.avast.com/antivirus