linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* drivers: media: platform/meson: does there exist a refcount error in function meson_ao_cec_probe
@ 2020-04-20  7:12 亿一
  0 siblings, 0 replies; 2+ messages in thread
From: 亿一 @ 2020-04-20  7:12 UTC (permalink / raw)
  To: narmstrong; +Cc: linux-media

Hi,all:
when reviewing code of function meson_ao_cec_probe:
In Linux kernel version before v5.4, function meson_ao_cec_probe hold
a notify  reference by cec_notifier_get, when err happens, it will
release notify
twice by cec_notifier_put, does here exist a redundant put in error
handling of cec_register_adapter return value?

static int meson_ao_cec_probe(struct platform_device *pdev)
{
    ao_cec->notify = cec_notifier_get(hdmi_dev);
    if (!ao_cec->notify)
        return -ENOMEM;

    ......

    ret = clk_set_rate (ao_cec->core, CEC_CLK_RATE);
    if (ret) {
        dev_err(&pdev->dev, "core clock set rate failed\n");
        goto out_probe_clk;
    }

    device_reset_optional(&pdev->dev);

    ao_cec->pdev = pdev;
    platform_set_drvdata(pdev, ao_cec);

    ret = cec_register_adapter(ao_cec->adap, &pdev->dev);
    if (ret < 0) {
        cec_notifier_put(ao_cec->notify);     // is it a redundant put here?
        goto out_probe_clk;
    }


    out_probe_clk:
        clk_disable_unprepare(ao_cec->core);

    out_probe_adapter:
        cec_delete_adapter(ao_cec->adap);

    out_probe_notify:
        cec_notifier_put(ao_cec->notify);

    dev_err(&pdev->dev, "CEC controller registration failed\n");

    return ret;
}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* drivers: media: platform/meson:  does there exist a refcount error in function  meson_ao_cec_probe
@ 2020-04-20  4:03 易林
  0 siblings, 0 replies; 2+ messages in thread
From: 易林 @ 2020-04-20  4:03 UTC (permalink / raw)
  To: narmstrong; +Cc: linux-media

Hi,all:
when reviewing code of function meson_ao_cec_probe:
In Linux kernel version before v5.4, function meson_ao_cec_probe hold a notify  reference by cec_notifier_get, when err happens, it will release notify 
twice by cec_notifier_put, does here exist a redundant put in error handling of cec_register_adapter return value?
    static int meson_ao_cec_probe(struct platform_device *pdev)
{
        ao_cec-&gt;notify = cec_notifier_get(hdmi_dev);
	if (!ao_cec-&gt;notify)
		return -ENOMEM;
	if (ret) {
		dev_err(&amp;pdev-&gt;dev, "core clock set rate failed\n");
		goto out_probe_clk;
	}

	device_reset_optional(&amp;pdev-&gt;dev);

	ao_cec-&gt;pdev = pdev;
	platform_set_drvdata(pdev, ao_cec);

	ret = cec_register_adapter(ao_cec-&gt;adap, &amp;pdev-&gt;dev);
	if (ret &lt; 0) {
		cec_notifier_put(ao_cec-&gt;notify); // a redundant put here ?
		goto out_probe_clk;
	}
	...
out_probe_clk:
	clk_disable_unprepare(ao_cec-&gt;core);

out_probe_adapter:
	cec_delete_adapter(ao_cec-&gt;adap);

out_probe_notify:
	cec_notifier_put(ao_cec-&gt;notify);

	dev_err(&amp;pdev-&gt;dev, "CEC controller registration failed\n");

	return ret;
}

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-20  7:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-20  7:12 drivers: media: platform/meson: does there exist a refcount error in function meson_ao_cec_probe 亿一
  -- strict thread matches above, loose matches on Subject: below --
2020-04-20  4:03 易林

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).