mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: oe-kbuild@lists.linux.dev,
	AngeloGioacchino Del Regno 
	<angelogioacchino.delregno@collabora.com>
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
	linux-kernel@vger.kernel.org, Stephen Boyd <sboyd@kernel.org>
Subject: drivers/clk/mediatek/clk-mt8173-apmixedsys.c:95 clk_mt8173_apmixed_probe() warn: passing zero to 'PTR_ERR'
Date: Tue, 7 Mar 2023 10:05:42 +0300	[thread overview]
Message-ID: <4dcf17f2-a74d-47fa-968e-67deb7d2498f@kili.mountain> (raw)

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@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.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


                 reply	other threads:[~2023-03-07  7:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4dcf17f2-a74d-47fa-968e-67deb7d2498f@kili.mountain \
    --to=error27@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    --cc=sboyd@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®