[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1521f09a-605a-746c-aabd-9cb036578a6f@lucaceresoli.net>
Date: Tue, 14 Dec 2021 22:32:36 +0100
From: Luca Ceresoli <luca@...aceresoli.net>
To: Dan Carpenter <dan.carpenter@...cle.com>, kbuild@...ts.01.org
Cc: lkp@...el.com, kbuild-all@...ts.01.org,
linux-kernel@...r.kernel.org,
Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
linux-clk <linux-clk@...r.kernel.org>
Subject: Re: drivers/pci/controller/dwc/pci-dra7xx.c:864 dra7xx_pcie_probe()
warn: 'dra7xx->clk' not released on lines: 759.
Hi Dan, All,
On 30/11/21 12:04, Dan Carpenter wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: d58071a8a76d779eedab38033ae4c821c30295a5
> commit: 5af9405397bfb90d6adab61d58f4d94c78166698 PCI: dra7xx: Get an optional clock
> config: powerpc64-randconfig-m031-20211128 (https://download.01.org/0day-ci/archive/20211130/202111301803.NOwoj4Jd-lkp@intel.com/config)
> compiler: powerpc64-linux-gcc (GCC) 11.2.0
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@...el.com>
> Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
>
> smatch warnings:
> drivers/pci/controller/dwc/pci-dra7xx.c:864 dra7xx_pcie_probe() warn: 'dra7xx->clk' not released on lines: 759.
>
> vim +864 drivers/pci/controller/dwc/pci-dra7xx.c
>
> e259c2926c016d drivers/pci/controller/dwc/pci-dra7xx.c Tony Lindgren 2021-03-10 684 static int dra7xx_pcie_probe(struct platform_device *pdev)
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 685 {
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 686 u32 reg;
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 687 int ret;
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 688 int irq;
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 689 int i;
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 690 int phy_count;
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 691 struct phy **phy;
> 7a4db656a6350f drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-10-09 692 struct device_link **link;
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 693 void __iomem *base;
> 442ec4c04d1235 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-02-15 694 struct dw_pcie *pci;
> 442ec4c04d1235 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-02-15 695 struct dra7xx_pcie *dra7xx;
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 696 struct device *dev = &pdev->dev;
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 697 struct device_node *np = dev->of_node;
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 698 char name[10];
> 602d38bc65aa29 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-01-11 699 struct gpio_desc *reset;
> 608793e27b3313 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-03-27 700 const struct of_device_id *match;
> 608793e27b3313 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-03-27 701 const struct dra7xx_pcie_of_data *data;
> 608793e27b3313 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-03-27 702 enum dw_pcie_device_mode mode;
> c232c0df9610bf drivers/pci/controller/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2019-01-24 703 u32 b1co_mode_sel_mask;
> 608793e27b3313 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-03-27 704
> 608793e27b3313 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-03-27 705 match = of_match_device(of_match_ptr(of_dra7xx_pcie_match), dev);
> 608793e27b3313 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-03-27 706 if (!match)
> 608793e27b3313 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-03-27 707 return -EINVAL;
> 608793e27b3313 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-03-27 708
> 608793e27b3313 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-03-27 709 data = (struct dra7xx_pcie_of_data *)match->data;
> 608793e27b3313 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-03-27 710 mode = (enum dw_pcie_device_mode)data->mode;
> c232c0df9610bf drivers/pci/controller/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2019-01-24 711 b1co_mode_sel_mask = data->b1co_mode_sel_mask;
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 712
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 713 dra7xx = devm_kzalloc(dev, sizeof(*dra7xx), GFP_KERNEL);
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 714 if (!dra7xx)
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 715 return -ENOMEM;
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 716
> 442ec4c04d1235 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-02-15 717 pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL);
> 442ec4c04d1235 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-02-15 718 if (!pci)
> 442ec4c04d1235 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-02-15 719 return -ENOMEM;
> 442ec4c04d1235 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-02-15 720
> 442ec4c04d1235 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-02-15 721 pci->dev = dev;
> 442ec4c04d1235 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-02-15 722 pci->ops = &dw_pcie_ops;
> 442ec4c04d1235 drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-02-15 723
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 724 irq = platform_get_irq(pdev, 0);
> caecb05c800081 drivers/pci/controller/dwc/pci-dra7xx.c Krzysztof WilczyĆski 2020-08-02 725 if (irq < 0)
> a0d21ba120d2c7 drivers/pci/dwc/pci-dra7xx.c Gustavo A. R. Silva 2017-08-09 726 return irq;
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 727
> c8a119779f5609 drivers/pci/controller/dwc/pci-dra7xx.c Wei Yongjun 2020-04-29 728 base = devm_platform_ioremap_resource_byname(pdev, "ti_conf");
> c8a119779f5609 drivers/pci/controller/dwc/pci-dra7xx.c Wei Yongjun 2020-04-29 729 if (IS_ERR(base))
> c8a119779f5609 drivers/pci/controller/dwc/pci-dra7xx.c Wei Yongjun 2020-04-29 730 return PTR_ERR(base);
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 731
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 732 phy_count = of_property_count_strings(np, "phy-names");
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 733 if (phy_count < 0) {
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 734 dev_err(dev, "unable to find the strings\n");
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 735 return phy_count;
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 736 }
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 737
> a86854d0c599b3 drivers/pci/dwc/pci-dra7xx.c Kees Cook 2018-06-12 738 phy = devm_kcalloc(dev, phy_count, sizeof(*phy), GFP_KERNEL);
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 739 if (!phy)
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 740 return -ENOMEM;
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 741
> a86854d0c599b3 drivers/pci/dwc/pci-dra7xx.c Kees Cook 2018-06-12 742 link = devm_kcalloc(dev, phy_count, sizeof(*link), GFP_KERNEL);
> 7a4db656a6350f drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-10-09 743 if (!link)
> 7a4db656a6350f drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-10-09 744 return -ENOMEM;
> 7a4db656a6350f drivers/pci/dwc/pci-dra7xx.c Kishon Vijay Abraham I 2017-10-09 745
> 5af9405397bfb9 drivers/pci/controller/dwc/pci-dra7xx.c Luca Ceresoli 2021-05-31 746 dra7xx->clk = devm_clk_get_optional(dev, NULL);
> 5af9405397bfb9 drivers/pci/controller/dwc/pci-dra7xx.c Luca Ceresoli 2021-05-31 747 if (IS_ERR(dra7xx->clk))
> 5af9405397bfb9 drivers/pci/controller/dwc/pci-dra7xx.c Luca Ceresoli 2021-05-31 748 return dev_err_probe(dev, PTR_ERR(dra7xx->clk),
> 5af9405397bfb9 drivers/pci/controller/dwc/pci-dra7xx.c Luca Ceresoli 2021-05-31 749 "clock request failed");
> 5af9405397bfb9 drivers/pci/controller/dwc/pci-dra7xx.c Luca Ceresoli 2021-05-31 750
> 5af9405397bfb9 drivers/pci/controller/dwc/pci-dra7xx.c Luca Ceresoli 2021-05-31 751 ret = clk_prepare_enable(dra7xx->clk);
> 5af9405397bfb9 drivers/pci/controller/dwc/pci-dra7xx.c Luca Ceresoli 2021-05-31 752 if (ret)
> 5af9405397bfb9 drivers/pci/controller/dwc/pci-dra7xx.c Luca Ceresoli 2021-05-31 753 return ret;
> 5af9405397bfb9 drivers/pci/controller/dwc/pci-dra7xx.c Luca Ceresoli 2021-05-31 754
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 755 for (i = 0; i < phy_count; i++) {
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 756 snprintf(name, sizeof(name), "pcie-phy%d", i);
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 757 phy[i] = devm_phy_get(dev, name);
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 758 if (IS_ERR(phy[i]))
> 47ff3de911a728 drivers/pci/host/pci-dra7xx.c Kishon Vijay Abraham I 2014-07-22 759 return PTR_ERR(phy[i]);
>
> Smatch wants an clk_unprepare_disable(dra7xx->clk) on failure paths.
+linux-clk
Looks like I assumed a devm-managed clock is disabled and unprepared on
error. But apparently I was wrong and only deallocation happens
automatically, at least it's what I could get from reading the code.
I'm sending a patch to fix this.
--
Luca
Powered by blists - more mailing lists