Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/7] cpufreq: ap806: fix possible object reference leak
       [not found] <1554082674-2049-1-git-send-email-wen.yang99@zte.com.cn>
@ 2019-04-01  1:37 ` Wen Yang
  2019-04-02 13:54   ` [1/7] cpufreq: ap806: Checking implementation of armada_8k_cpufreq_init() Markus Elfring
                     ` (2 more replies)
  2019-04-01  1:37 ` [PATCH 2/7] cpufreq: imx6q: " Wen Yang
  1 sibling, 3 replies; 5+ messages in thread
From: Wen Yang @ 2019-04-01  1:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: wang.yi59, Andrew Lunn, Jason Cooper, linux-pm, Viresh Kumar,
	Gregory Clement, Rafael J. Wysocki, Wen Yang, linux-arm-kernel,
	Sebastian Hesselbarth

The call to of_find_compatible_node 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/armada-8k-cpufreq.c:187:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 130, but without a corresponding object release within this function.
./drivers/cpufreq/armada-8k-cpufreq.c:191:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 130, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Gregory Clement <gregory.clement@bootlin.com>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/cpufreq/armada-8k-cpufreq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/cpufreq/armada-8k-cpufreq.c b/drivers/cpufreq/armada-8k-cpufreq.c
index b3f4bd6..988ebc3 100644
--- a/drivers/cpufreq/armada-8k-cpufreq.c
+++ b/drivers/cpufreq/armada-8k-cpufreq.c
@@ -132,6 +132,7 @@ static int __init armada_8k_cpufreq_init(void)
 		of_node_put(node);
 		return -ENODEV;
 	}
+	of_node_put(node);
 
 	nb_cpus = num_possible_cpus();
 	freq_tables = kcalloc(nb_cpus, sizeof(*freq_tables), GFP_KERNEL);
-- 
2.9.5


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/7] cpufreq: imx6q: fix possible object reference leak
       [not found] <1554082674-2049-1-git-send-email-wen.yang99@zte.com.cn>
  2019-04-01  1:37 ` [PATCH 1/7] cpufreq: ap806: fix possible object reference leak Wen Yang
@ 2019-04-01  1:37 ` Wen Yang
  1 sibling, 0 replies; 5+ messages in thread
From: Wen Yang @ 2019-04-01  1:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: wang.yi59, Fabio Estevam, linux-pm, Viresh Kumar, Sascha Hauer,
	Rafael J. Wysocki, NXP Linux Team, Pengutronix Kernel Team,
	Shawn Guo, Wen Yang, linux-arm-kernel

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
---
 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);
-- 
2.9.5


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [1/7] cpufreq: ap806: Checking implementation of armada_8k_cpufreq_init()
  2019-04-01  1:37 ` [PATCH 1/7] cpufreq: ap806: fix possible object reference leak Wen Yang
  2019-04-02 13:54   ` [1/7] cpufreq: ap806: Checking implementation of armada_8k_cpufreq_init() Markus Elfring
@ 2019-04-02 13:54   ` Markus Elfring
  2019-04-08 10:21   ` [PATCH 1/7] cpufreq: ap806: fix possible object reference leak Viresh Kumar
  2 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2019-04-02 13:54 UTC (permalink / raw)
  To: Wen Yang, Gregory Clement, Viresh Kumar, kernel-janitors
  Cc: Yi Wang, Andrew Lunn, Jason Cooper, linux-pm, Rafael J. Wysocki,
	linux-kernel, linux-arm-kernel, Sebastian Hesselbarth

> @@ -132,6 +132,7 @@ static int __init armada_8k_cpufreq_init(void)
>  		of_node_put(node);
>  		return -ENODEV;
>  	}
> +	of_node_put(node);
>
>  	nb_cpus = num_possible_cpus();
>  	freq_tables = kcalloc(nb_cpus, sizeof(*freq_tables), GFP_KERNEL);

Would another null pointer check be safer for this memory allocation?
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/cpufreq/armada-8k-cpufreq.c?id=05d08e2995cbe6efdb993482ee0d38a77040861a#n137

Regards,
Markus

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [1/7] cpufreq: ap806: Checking implementation of armada_8k_cpufreq_init()
  2019-04-01  1:37 ` [PATCH 1/7] cpufreq: ap806: fix possible object reference leak Wen Yang
@ 2019-04-02 13:54   ` Markus Elfring
  2019-04-02 13:54   ` Markus Elfring
  2019-04-08 10:21   ` [PATCH 1/7] cpufreq: ap806: fix possible object reference leak Viresh Kumar
  2 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2019-04-02 13:54 UTC (permalink / raw)
  To: Wen Yang, Gregory Clement, Viresh Kumar, kernel-janitors
  Cc: Yi Wang, Andrew Lunn, Jason Cooper, linux-pm, Rafael J. Wysocki,
	linux-kernel, linux-arm-kernel, Sebastian Hesselbarth

> @@ -132,6 +132,7 @@ static int __init armada_8k_cpufreq_init(void)
>  		of_node_put(node);
>  		return -ENODEV;
>  	}
> +	of_node_put(node);
>
>  	nb_cpus = num_possible_cpus();
>  	freq_tables = kcalloc(nb_cpus, sizeof(*freq_tables), GFP_KERNEL);

Would another null pointer check be safer for this memory allocation?
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/cpufreq/armada-8k-cpufreq.c?id=05d08e2995cbe6efdb993482ee0d38a77040861a#n137

Regards,
Markus

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/7] cpufreq: ap806: fix possible object reference leak
  2019-04-01  1:37 ` [PATCH 1/7] cpufreq: ap806: fix possible object reference leak Wen Yang
  2019-04-02 13:54   ` [1/7] cpufreq: ap806: Checking implementation of armada_8k_cpufreq_init() Markus Elfring
  2019-04-02 13:54   ` Markus Elfring
@ 2019-04-08 10:21   ` Viresh Kumar
  2 siblings, 0 replies; 5+ messages in thread
From: Viresh Kumar @ 2019-04-08 10:21 UTC (permalink / raw)
  To: Wen Yang
  Cc: wang.yi59, Andrew Lunn, Jason Cooper, linux-pm, Gregory Clement,
	Rafael J. Wysocki, linux-kernel, linux-arm-kernel,
	Sebastian Hesselbarth

On 01-04-19, 09:37, Wen Yang wrote:
> The call to of_find_compatible_node 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/armada-8k-cpufreq.c:187:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 130, but without a corresponding object release within this function.
> ./drivers/cpufreq/armada-8k-cpufreq.c:191:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 130, but without a corresponding object release within this function.
> 
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> Cc: Jason Cooper <jason@lakedaemon.net>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Gregory Clement <gregory.clement@bootlin.com>
> Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-pm@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  drivers/cpufreq/armada-8k-cpufreq.c | 1 +
>  1 file changed, 1 insertion(+)

I haven't received the cover-letter and patch 4/7 (because the tags in that
commit were incorrect). I have applied all the 7 patches to my cpufreq tree
though.

Thanks.

-- 
viresh

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-04-08 10:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1554082674-2049-1-git-send-email-wen.yang99@zte.com.cn>
2019-04-01  1:37 ` [PATCH 1/7] cpufreq: ap806: fix possible object reference leak Wen Yang
2019-04-02 13:54   ` [1/7] cpufreq: ap806: Checking implementation of armada_8k_cpufreq_init() Markus Elfring
2019-04-02 13:54   ` Markus Elfring
2019-04-08 10:21   ` [PATCH 1/7] cpufreq: ap806: fix possible object reference leak Viresh Kumar
2019-04-01  1:37 ` [PATCH 2/7] cpufreq: imx6q: " Wen Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox