* [PATCH] thermal: armada: fix incorrect check for drvdata allocation failure
@ 2018-07-30 12:27 ` Colin King
0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2018-07-30 12:27 UTC (permalink / raw)
To: Zhang Rui, Eduardo Valentin, linux-pm; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently the drvdata allocation failure is being incorrectly checked by
checking priv and not drvdata. Fix this and also free priv to fix a
memory leak.
Detected by Coverity Scan, CID#1472102 ("Logically dead code")
Fixes: c9899c183921 ("thermal: armada: use the resource managed registration helper alternative")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/thermal/armada_thermal.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
index 4164a5a4e480..b164fd9f21ac 100644
--- a/drivers/thermal/armada_thermal.c
+++ b/drivers/thermal/armada_thermal.c
@@ -611,8 +611,10 @@ static int armada_thermal_probe(struct platform_device *pdev)
return -ENOMEM;
drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
- if (!priv)
+ if (!drvdata) {
+ devm_kfree(&pdev->dev, priv);
return -ENOMEM;
+ }
priv->dev = &pdev->dev;
priv->data = (struct armada_thermal_data *)match->data;
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] thermal: armada: fix incorrect check for drvdata allocation failure
@ 2018-07-30 12:27 ` Colin King
0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2018-07-30 12:27 UTC (permalink / raw)
To: Zhang Rui, Eduardo Valentin, linux-pm; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently the drvdata allocation failure is being incorrectly checked by
checking priv and not drvdata. Fix this and also free priv to fix a
memory leak.
Detected by Coverity Scan, CID#1472102 ("Logically dead code")
Fixes: c9899c183921 ("thermal: armada: use the resource managed registration helper alternative")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/thermal/armada_thermal.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
index 4164a5a4e480..b164fd9f21ac 100644
--- a/drivers/thermal/armada_thermal.c
+++ b/drivers/thermal/armada_thermal.c
@@ -611,8 +611,10 @@ static int armada_thermal_probe(struct platform_device *pdev)
return -ENOMEM;
drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
- if (!priv)
+ if (!drvdata) {
+ devm_kfree(&pdev->dev, priv);
return -ENOMEM;
+ }
priv->dev = &pdev->dev;
priv->data = (struct armada_thermal_data *)match->data;
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] thermal: armada: fix incorrect check for drvdata allocation failure
2018-07-30 12:27 ` Colin King
@ 2018-07-30 14:14 ` Daniel Lezcano
-1 siblings, 0 replies; 6+ messages in thread
From: Daniel Lezcano @ 2018-07-30 14:14 UTC (permalink / raw)
To: Colin King, Zhang Rui, Eduardo Valentin, linux-pm
Cc: kernel-janitors, linux-kernel
Hi Colin,
On 30/07/2018 14:27, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the drvdata allocation failure is being incorrectly checked by
> checking priv and not drvdata. Fix this and also free priv to fix a
> memory leak.
>
> Detected by Coverity Scan, CID#1472102 ("Logically dead code")
>
> Fixes: c9899c183921 ("thermal: armada: use the resource managed registration helper alternative")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/thermal/armada_thermal.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
> index 4164a5a4e480..b164fd9f21ac 100644
> --- a/drivers/thermal/armada_thermal.c
> +++ b/drivers/thermal/armada_thermal.c
> @@ -611,8 +611,10 @@ static int armada_thermal_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
> - if (!priv)
> + if (!drvdata) {
> + devm_kfree(&pdev->dev, priv);
This is not necessary, resources will be free when the driver is
destroyed after the probe fails.
> return -ENOMEM;
> + }
>
> priv->dev = &pdev->dev;
> priv->data = (struct armada_thermal_data *)match->data;
Thanks for sending this fix. However, another fix was already submitted
for this.
-- Daniel
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] thermal: armada: fix incorrect check for drvdata allocation failure
@ 2018-07-30 14:14 ` Daniel Lezcano
0 siblings, 0 replies; 6+ messages in thread
From: Daniel Lezcano @ 2018-07-30 14:14 UTC (permalink / raw)
To: Colin King, Zhang Rui, Eduardo Valentin, linux-pm
Cc: kernel-janitors, linux-kernel
Hi Colin,
On 30/07/2018 14:27, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the drvdata allocation failure is being incorrectly checked by
> checking priv and not drvdata. Fix this and also free priv to fix a
> memory leak.
>
> Detected by Coverity Scan, CID#1472102 ("Logically dead code")
>
> Fixes: c9899c183921 ("thermal: armada: use the resource managed registration helper alternative")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/thermal/armada_thermal.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
> index 4164a5a4e480..b164fd9f21ac 100644
> --- a/drivers/thermal/armada_thermal.c
> +++ b/drivers/thermal/armada_thermal.c
> @@ -611,8 +611,10 @@ static int armada_thermal_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
> - if (!priv)
> + if (!drvdata) {
> + devm_kfree(&pdev->dev, priv);
This is not necessary, resources will be free when the driver is
destroyed after the probe fails.
> return -ENOMEM;
> + }
>
> priv->dev = &pdev->dev;
> priv->data = (struct armada_thermal_data *)match->data;
Thanks for sending this fix. However, another fix was already submitted
for this.
-- Daniel
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] thermal: armada: fix incorrect check for drvdata allocation failure
2018-07-30 12:27 ` Colin King
@ 2018-08-20 18:52 ` Eduardo Valentin
-1 siblings, 0 replies; 6+ messages in thread
From: Eduardo Valentin @ 2018-08-20 18:52 UTC (permalink / raw)
To: Colin King; +Cc: Zhang Rui, linux-pm, kernel-janitors, linux-kernel
hello Colin,
On Mon, Jul 30, 2018 at 01:27:16PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the drvdata allocation failure is being incorrectly checked by
> checking priv and not drvdata. Fix this and also free priv to fix a
> memory leak.
>
> Detected by Coverity Scan, CID#1472102 ("Logically dead code")
>
> Fixes: c9899c183921 ("thermal: armada: use the resource managed registration helper alternative")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/thermal/armada_thermal.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
> index 4164a5a4e480..b164fd9f21ac 100644
> --- a/drivers/thermal/armada_thermal.c
> +++ b/drivers/thermal/armada_thermal.c
> @@ -611,8 +611,10 @@ static int armada_thermal_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
> - if (!priv)
> + if (!drvdata) {
Thanks for the fix but, I already collected this patch:
84b64de597bc ("thermal: armada: fix copy-paste error in armada_thermal_probe()")
which fixes the same issue you are addressing here.
> + devm_kfree(&pdev->dev, priv);
As already mentioned by Daniel, the above is not necessary, as it is a
devm_* helper.
BR,
> return -ENOMEM;
> + }
>
> priv->dev = &pdev->dev;
> priv->data = (struct armada_thermal_data *)match->data;
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] thermal: armada: fix incorrect check for drvdata allocation failure
@ 2018-08-20 18:52 ` Eduardo Valentin
0 siblings, 0 replies; 6+ messages in thread
From: Eduardo Valentin @ 2018-08-20 18:52 UTC (permalink / raw)
To: Colin King; +Cc: Zhang Rui, linux-pm, kernel-janitors, linux-kernel
hello Colin,
On Mon, Jul 30, 2018 at 01:27:16PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the drvdata allocation failure is being incorrectly checked by
> checking priv and not drvdata. Fix this and also free priv to fix a
> memory leak.
>
> Detected by Coverity Scan, CID#1472102 ("Logically dead code")
>
> Fixes: c9899c183921 ("thermal: armada: use the resource managed registration helper alternative")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/thermal/armada_thermal.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
> index 4164a5a4e480..b164fd9f21ac 100644
> --- a/drivers/thermal/armada_thermal.c
> +++ b/drivers/thermal/armada_thermal.c
> @@ -611,8 +611,10 @@ static int armada_thermal_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
> - if (!priv)
> + if (!drvdata) {
Thanks for the fix but, I already collected this patch:
84b64de597bc ("thermal: armada: fix copy-paste error in armada_thermal_probe()")
which fixes the same issue you are addressing here.
> + devm_kfree(&pdev->dev, priv);
As already mentioned by Daniel, the above is not necessary, as it is a
devm_* helper.
BR,
> return -ENOMEM;
> + }
>
> priv->dev = &pdev->dev;
> priv->data = (struct armada_thermal_data *)match->data;
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-08-20 18:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-30 12:27 [PATCH] thermal: armada: fix incorrect check for drvdata allocation failure Colin King
2018-07-30 12:27 ` Colin King
2018-07-30 14:14 ` Daniel Lezcano
2018-07-30 14:14 ` Daniel Lezcano
2018-08-20 18:52 ` Eduardo Valentin
2018-08-20 18:52 ` Eduardo Valentin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.