cpufreq: imx6q: fix possible object reference leak [Linux 5.2]

cpufreq: imx6q: fix possible object reference leak [Linux 5.2]

This Linux kernel change "cpufreq: imx6q: fix possible object reference leak" is included in the Linux 5.2 release. This change is authored by Wen Yang <wen.yang99 [at] zte.com.cn> on Mon Apr 1 09:37:49 2019 +0800. The commit for this change in Linux stable tree is ddb64c5 (patch).

cpufreq: imx6q: fix possible object reference leak

The call to of_node_get returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
./drivers/cpufreq/imx6q-cpufreq.c:391:4-10: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 348, but without a corresponding object release within this function.
./drivers/cpufreq/imx6q-cpufreq.c:395:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 348, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

There are 4 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/cpufreq/imx6q-cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index a4ff09f..3e17560 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -388,11 +388,11 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
        ret = imx6ul_opp_check_speed_grading(cpu_dev);
        if (ret) {
            if (ret == -EPROBE_DEFER)
-               return ret;
+               goto put_node;

            dev_err(cpu_dev, "failed to read ocotp: %d\n",
                ret);
-           return ret;
+           goto put_node;
        }
    } else {
        imx6q_opp_check_speed_grading(cpu_dev);

Leave a Reply

Your email address will not be published. Required fields are marked *