Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp312274pxb; Mon, 2 Nov 2020 23:29:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZmzejTV4CAXnm8QP4fE36y8Pc2G6TqDd9WQKLI3wdOXAYjHqIVd/dLIsPyStEoC8fft/9 X-Received: by 2002:a05:6402:b3b:: with SMTP id bo27mr6080016edb.376.1604388589279; Mon, 02 Nov 2020 23:29:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604388589; cv=none; d=google.com; s=arc-20160816; b=sjdnrhRXbz0Sn5eDrnkNKlsKtf7DKFoS1J3tG6ZlCrH5AhcJG6gnIQn8Dzc+3xMxgh sAyc8PNdEag2mkpDrpXwXe66QMV5VZZZtlE/10gNRMadz/6Iy9bY8xzNtxEERBWNpDuP u9xYm6/mxHJZQpvlXcVR2QcI95Beln6HEcMuW3aE1HJ6YDg4a/hJYuE+koAr/YeGXQqY WLCYLV5xvbH/727KlEG9lQ7L9zsGZxCQKpUtw7s/WwZV1ophqgas2ZzWzpqGdKz2wTKt Sau3jCkkBEZLKgk78C23ZNNo4YSgxefQVnjO9M9q14wbt6+bTv1g3PwhwLYKwUYQt4/Z Wmwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=8+kVPsumcG21Vkm1XSsI6cV1slpsZAcvObDEG8CPqu4=; b=eLJSTJDUvsGSP6PXm7BfiZSmBDY8THEelAuiuszRkH6koykxHzgR99s+JG/UldTRTw 9MCVF3pEFMBOJoo7HrpOb6Fk5hNgAeOSPmxaBIXm9AqlqeLHc6UHfCKVNKg9IJk5/XVl jOeKKWnmyoQ+/SRo1Cn5ZxwPQ8lG2SxS116wGvkmE0o8ykyo5P/9SzCsuuPH897vNJEQ JfTImzZGFCz6eYDGnC8agWsSErOg9cMrN+BLHzLDb0NcqawHjvekmsB1+CtUtbtVLmr8 a73jHvLIdhsTNg5Epw429/8Waq0HvFqvvemv7lmEGSNXHO05uFCtjxlJQdmDc588eMO+ Y+NA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lw7si12000527ejb.149.2020.11.02.23.29.27; Mon, 02 Nov 2020 23:29:49 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727843AbgKCH1u (ORCPT + 99 others); Tue, 3 Nov 2020 02:27:50 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:7407 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725968AbgKCH1u (ORCPT ); Tue, 3 Nov 2020 02:27:50 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4CQLwD6rLMz71hY; Tue, 3 Nov 2020 15:27:40 +0800 (CST) Received: from [10.174.177.149] (10.174.177.149) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.487.0; Tue, 3 Nov 2020 15:27:40 +0800 Subject: Re: [PATCH] PCI: v3: fix missing clk_disable_unprepare() on error in v3_pci_probe To: Rob Herring CC: Linus Walleij , Lorenzo Pieralisi , Bjorn Helgaas , PCI , "linux-kernel@vger.kernel.org" References: <20201030013427.54086-1-miaoqinglang@huawei.com> From: miaoqinglang Message-ID: <8f3677d9-6443-e550-553f-d8d61e8e8241@huawei.com> Date: Tue, 3 Nov 2020 15:27:40 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.149] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2020/11/2 21:48, Rob Herring 写道: > On Thu, Oct 29, 2020 at 8:28 PM Qinglang Miao wrote: >> >> Fix the missing clk_disable_unprepare() before return >> from v3_pci_probe() in the error handling case. >> >> Signed-off-by: Qinglang Miao >> --- >> drivers/pci/controller/pci-v3-semi.c | 14 +++++++++++--- >> 1 file changed, 11 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/pci/controller/pci-v3-semi.c b/drivers/pci/controller/pci-v3-semi.c >> index 154a53986..e24abc5b4 100644 >> --- a/drivers/pci/controller/pci-v3-semi.c >> +++ b/drivers/pci/controller/pci-v3-semi.c >> @@ -739,8 +739,10 @@ static int v3_pci_probe(struct platform_device *pdev) >> >> regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); >> v3->base = devm_ioremap_resource(dev, regs); >> - if (IS_ERR(v3->base)) >> + if (IS_ERR(v3->base)) { >> + clk_disable_unprepare(clk); > > You can reorder things moving the clock enable later (after mapping > resources, but before devm_request_irq) and avoid some of these. Also > move this check down: > > if (readl(v3->base + V3_LB_IO_BASE) != (regs->start >> 16)) > Hi Rob, I've sent a new patch which reorder things and cover all error branches. But I'm not sure why and where should I move this check down: if (readl(v3->base + V3_LB_IO_BASE) != (regs->start >> 16)). So I didn't move it in current version. If you think it's still necessary, please let me know. Thanks. > >> return PTR_ERR(v3->base); >> + } >> /* >> * The hardware has a register with the physical base address >> * of the V3 controller itself, verify that this is the same >> @@ -754,17 +756,22 @@ static int v3_pci_probe(struct platform_device *pdev) >> regs = platform_get_resource(pdev, IORESOURCE_MEM, 1); >> if (resource_size(regs) != SZ_16M) { >> dev_err(dev, "config mem is not 16MB!\n"); >> + clk_disable_unprepare(clk); >> return -EINVAL; >> } >> v3->config_mem = regs->start; >> v3->config_base = devm_ioremap_resource(dev, regs); >> - if (IS_ERR(v3->config_base)) >> + if (IS_ERR(v3->config_base)) { >> + clk_disable_unprepare(clk); >> return PTR_ERR(v3->config_base); >> + } >> >> /* Get and request error IRQ resource */ >> irq = platform_get_irq(pdev, 0); >> - if (irq < 0) >> + if (irq < 0) { >> + clk_disable_unprepare(clk); >> return irq; >> + } >> >> ret = devm_request_irq(dev, irq, v3_irq, 0, >> "PCIv3 error", v3); >> @@ -772,6 +779,7 @@ static int v3_pci_probe(struct platform_device *pdev) >> dev_err(dev, >> "unable to request PCIv3 error IRQ %d (%d)\n", >> irq, ret); >> + clk_disable_unprepare(clk); >> return ret; > > You still leave the clock enabled if pci_host_probe() fails. > > Rob > . >