lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Tue, 7 Mar 2023 10:05:42 +0300
From:   Dan Carpenter <error27@...il.com>
To:     oe-kbuild@...ts.linux.dev,
        AngeloGioacchino Del Regno 
        <angelogioacchino.delregno@...labora.com>
Cc:     lkp@...el.com, oe-kbuild-all@...ts.linux.dev,
        linux-kernel@...r.kernel.org, Stephen Boyd <sboyd@...nel.org>
Subject: drivers/clk/mediatek/clk-mt8173-apmixedsys.c:95
 clk_mt8173_apmixed_probe() warn: passing zero to 'PTR_ERR'

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   fe15c26ee26efa11741a7b632e9f23b01aca4cc6
commit: 4c02c9af3cb9449cd176300b288e8addb5083934 clk: mediatek: mt8173: Break down clock drivers and allow module build
config: microblaze-randconfig-m031-20230305 (https://download.01.org/0day-ci/archive/20230307/202303070207.8wVd9MFI-lkp@intel.com/config)
compiler: microblaze-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
| Reported-by: Dan Carpenter <error27@...il.com>
| Link: https://lore.kernel.org/r/202303070207.8wVd9MFI-lkp@intel.com/

smatch warnings:
drivers/clk/mediatek/clk-mt8173-apmixedsys.c:95 clk_mt8173_apmixed_probe() warn: passing zero to 'PTR_ERR'
drivers/clk/mediatek/clk-mt8173-apmixedsys.c:130 clk_mt8173_apmixed_probe() warn: 'base' from of_iomap() not released on lines: 99.

vim +/PTR_ERR +95 drivers/clk/mediatek/clk-mt8173-apmixedsys.c

4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20   85  static int clk_mt8173_apmixed_probe(struct platform_device *pdev)
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20   86  {
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20   87  	struct device_node *node = pdev->dev.of_node;
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20   88  	struct clk_hw_onecell_data *clk_data;
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20   89  	void __iomem *base;
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20   90  	struct clk_hw *hw;
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20   91  	int r;
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20   92  
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20   93  	base = of_iomap(node, 0);
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20   94  	if (!base)
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  @95  		return PTR_ERR(base);

return -ENOMEM;  This currently returns success.

4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20   96  
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20   97  	clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20   98  	if (IS_ERR_OR_NULL(clk_data))

This IS_ERR_OR_NULL() is kind of wrong.  It should just be if (!clk_data).
I wrote a blog about this:
https://staticthinking.wordpress.com/2022/08/01/mixing-error-pointers-and-null/

4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20   99  		return -ENOMEM;

of_iounmap(base)?

4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  100  
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  101  	r = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  102  	if (r)
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  103  		goto free_clk_data;
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  104  
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  105  	hw = mtk_clk_register_ref2usb_tx("ref2usb_tx", "clk26m", base + REGOFF_REF2USB);
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  106  	if (IS_ERR(hw)) {
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  107  		r = PTR_ERR(hw);
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  108  		dev_err(&pdev->dev, "Failed to register ref2usb_tx: %d\n", r);
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  109  		goto unregister_plls;
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  110  	}
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  111  	clk_data->hws[CLK_APMIXED_REF2USB_TX] = hw;
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  112  
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  113  	hw = devm_clk_hw_register_divider(&pdev->dev, "hdmi_ref", "tvdpll_594m", 0,
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  114  					  base + REGOFF_HDMI_REF, 16, 3,
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  115  					  CLK_DIVIDER_POWER_OF_TWO, NULL);
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  116  	clk_data->hws[CLK_APMIXED_HDMI_REF] = hw;
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  117  
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  118  	r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  119  	if (r)
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  120  		goto unregister_ref2usb;
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  121  
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  122  	return 0;
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  123  
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  124  unregister_ref2usb:
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  125  	mtk_clk_unregister_ref2usb_tx(clk_data->hws[CLK_APMIXED_REF2USB_TX]);
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  126  unregister_plls:
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  127  	mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  128  free_clk_data:
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  129  	mtk_free_clk_data(clk_data);
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20 @130  	return r;
4c02c9af3cb944 AngeloGioacchino Del Regno 2023-01-20  131  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ