* [PATCH] clocksource/drivers/timer-atmel-pit: properly handle error cases
@ 2018-04-25 10:14 ` Alexandre Belloni
0 siblings, 0 replies; 10+ messages in thread
From: Alexandre Belloni @ 2018-04-25 10:14 UTC (permalink / raw)
To: Daniel Lezcano
Cc: Thomas Gleixner, Nicolas Ferre, Boris Brezillon,
linux-arm-kernel, linux-kernel, Alexandre Belloni
smatch now reports a possible leak:
smatch warnings:
drivers/clocksource/timer-atmel-pit.c:183 at91sam926x_pit_dt_init() warn: possible memory leak of 'data'
Ensure data is freed before exiting with an error.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/clocksource/timer-atmel-pit.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index ec8a4376f74f..2fab18fae4fc 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -180,26 +180,29 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
data->base = of_iomap(node, 0);
if (!data->base) {
pr_err("Could not map PIT address\n");
- return -ENXIO;
+ ret = -ENXIO;
+ goto exit;
}
data->mck = of_clk_get(node, 0);
if (IS_ERR(data->mck)) {
pr_err("Unable to get mck clk\n");
- return PTR_ERR(data->mck);
+ ret = PTR_ERR(data->mck);
+ goto exit;
}
ret = clk_prepare_enable(data->mck);
if (ret) {
pr_err("Unable to enable mck\n");
- return ret;
+ goto exit;
}
/* Get the interrupts property */
data->irq = irq_of_parse_and_map(node, 0);
if (!data->irq) {
pr_err("Unable to get IRQ from DT\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto exit;
}
/*
@@ -227,7 +230,7 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
ret = clocksource_register_hz(&data->clksrc, pit_rate);
if (ret) {
pr_err("Failed to register clocksource\n");
- return ret;
+ goto exit;
}
/* Set up irq handler */
@@ -236,7 +239,8 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
"at91_tick", data);
if (ret) {
pr_err("Unable to setup IRQ\n");
- return ret;
+ clocksource_unregister(&data->clksrc);
+ goto exit;
}
/* Set up and register clockevents */
@@ -254,6 +258,10 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
clockevents_register_device(&data->clkevt);
return 0;
+
+exit:
+ kfree(data);
+ return ret;
}
TIMER_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit",
at91sam926x_pit_dt_init);
--
2.17.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH] clocksource/drivers/timer-atmel-pit: properly handle error cases
@ 2018-04-25 10:14 ` Alexandre Belloni
0 siblings, 0 replies; 10+ messages in thread
From: Alexandre Belloni @ 2018-04-25 10:14 UTC (permalink / raw)
To: linux-arm-kernel
smatch now reports a possible leak:
smatch warnings:
drivers/clocksource/timer-atmel-pit.c:183 at91sam926x_pit_dt_init() warn: possible memory leak of 'data'
Ensure data is freed before exiting with an error.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/clocksource/timer-atmel-pit.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index ec8a4376f74f..2fab18fae4fc 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -180,26 +180,29 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
data->base = of_iomap(node, 0);
if (!data->base) {
pr_err("Could not map PIT address\n");
- return -ENXIO;
+ ret = -ENXIO;
+ goto exit;
}
data->mck = of_clk_get(node, 0);
if (IS_ERR(data->mck)) {
pr_err("Unable to get mck clk\n");
- return PTR_ERR(data->mck);
+ ret = PTR_ERR(data->mck);
+ goto exit;
}
ret = clk_prepare_enable(data->mck);
if (ret) {
pr_err("Unable to enable mck\n");
- return ret;
+ goto exit;
}
/* Get the interrupts property */
data->irq = irq_of_parse_and_map(node, 0);
if (!data->irq) {
pr_err("Unable to get IRQ from DT\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto exit;
}
/*
@@ -227,7 +230,7 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
ret = clocksource_register_hz(&data->clksrc, pit_rate);
if (ret) {
pr_err("Failed to register clocksource\n");
- return ret;
+ goto exit;
}
/* Set up irq handler */
@@ -236,7 +239,8 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
"at91_tick", data);
if (ret) {
pr_err("Unable to setup IRQ\n");
- return ret;
+ clocksource_unregister(&data->clksrc);
+ goto exit;
}
/* Set up and register clockevents */
@@ -254,6 +258,10 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
clockevents_register_device(&data->clkevt);
return 0;
+
+exit:
+ kfree(data);
+ return ret;
}
TIMER_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit",
at91sam926x_pit_dt_init);
--
2.17.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] clocksource/drivers/timer-atmel-pit: properly handle error cases
2018-04-25 10:14 ` Alexandre Belloni
@ 2018-05-01 8:36 ` Daniel Lezcano
-1 siblings, 0 replies; 10+ messages in thread
From: Daniel Lezcano @ 2018-05-01 8:36 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Thomas Gleixner, Nicolas Ferre, Boris Brezillon,
linux-arm-kernel, linux-kernel
On Wed, Apr 25, 2018 at 12:14:39PM +0200, Alexandre Belloni wrote:
> smatch now reports a possible leak:
>
> smatch warnings:
> drivers/clocksource/timer-atmel-pit.c:183 at91sam926x_pit_dt_init() warn: possible memory leak of 'data'
>
> Ensure data is freed before exiting with an error.
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> ---
Applied for 4.17-rc
--
<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] 10+ messages in thread
* [PATCH] clocksource/drivers/timer-atmel-pit: properly handle error cases
@ 2018-05-01 8:36 ` Daniel Lezcano
0 siblings, 0 replies; 10+ messages in thread
From: Daniel Lezcano @ 2018-05-01 8:36 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Apr 25, 2018 at 12:14:39PM +0200, Alexandre Belloni wrote:
> smatch now reports a possible leak:
>
> smatch warnings:
> drivers/clocksource/timer-atmel-pit.c:183 at91sam926x_pit_dt_init() warn: possible memory leak of 'data'
>
> Ensure data is freed before exiting with an error.
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> ---
Applied for 4.17-rc
--
<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] 10+ messages in thread
* Re: [PATCH] clocksource/drivers/timer-atmel-pit: properly handle error cases
2018-05-01 8:36 ` Daniel Lezcano
@ 2018-09-26 12:38 ` Nicolas Ferre
-1 siblings, 0 replies; 10+ messages in thread
From: Nicolas Ferre @ 2018-09-26 12:38 UTC (permalink / raw)
To: Daniel Lezcano
Cc: Alexandre Belloni, Thomas Gleixner, Boris Brezillon,
linux-arm-kernel, linux-kernel, Cristian Birsan
Daniel,
On 01/05/2018 at 10:36, Daniel Lezcano wrote:
> On Wed, Apr 25, 2018 at 12:14:39PM +0200, Alexandre Belloni wrote:
>> smatch now reports a possible leak:
>>
>> smatch warnings:
>> drivers/clocksource/timer-atmel-pit.c:183 at91sam926x_pit_dt_init() warn: possible memory leak of 'data'
>>
>> Ensure data is freed before exiting with an error.
>>
>> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
>> ---
>
> Applied for 4.17-rc
We don't see it in Mainline as of 4.19-rc neither in linux-next. Has it
been forgotten?
Thanks for your help. Best regards,
--
Nicolas Ferre
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] clocksource/drivers/timer-atmel-pit: properly handle error cases
@ 2018-09-26 12:38 ` Nicolas Ferre
0 siblings, 0 replies; 10+ messages in thread
From: Nicolas Ferre @ 2018-09-26 12:38 UTC (permalink / raw)
To: linux-arm-kernel
Daniel,
On 01/05/2018 at 10:36, Daniel Lezcano wrote:
> On Wed, Apr 25, 2018 at 12:14:39PM +0200, Alexandre Belloni wrote:
>> smatch now reports a possible leak:
>>
>> smatch warnings:
>> drivers/clocksource/timer-atmel-pit.c:183 at91sam926x_pit_dt_init() warn: possible memory leak of 'data'
>>
>> Ensure data is freed before exiting with an error.
>>
>> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
>> ---
>
> Applied for 4.17-rc
We don't see it in Mainline as of 4.19-rc neither in linux-next. Has it
been forgotten?
Thanks for your help. Best regards,
--
Nicolas Ferre
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] clocksource/drivers/timer-atmel-pit: properly handle error cases
2018-09-26 12:38 ` Nicolas Ferre
@ 2018-09-27 10:00 ` Daniel Lezcano
-1 siblings, 0 replies; 10+ messages in thread
From: Daniel Lezcano @ 2018-09-27 10:00 UTC (permalink / raw)
To: Nicolas Ferre
Cc: Alexandre Belloni, Thomas Gleixner, Boris Brezillon,
linux-arm-kernel, linux-kernel, Cristian Birsan
On 26/09/2018 14:38, Nicolas Ferre wrote:
> Daniel,
>
> On 01/05/2018 at 10:36, Daniel Lezcano wrote:
>> On Wed, Apr 25, 2018 at 12:14:39PM +0200, Alexandre Belloni wrote:
>>> smatch now reports a possible leak:
>>>
>>> smatch warnings:
>>> drivers/clocksource/timer-atmel-pit.c:183 at91sam926x_pit_dt_init()
>>> warn: possible memory leak of 'data'
>>>
>>> Ensure data is freed before exiting with an error.
>>>
>>> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>>> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
>>> ---
>>
>> Applied for 4.17-rc
>
> We don't see it in Mainline as of 4.19-rc neither in linux-next. Has it
> been forgotten?
Yes, my bad. I thought it was merge in tip:timers/urgent
Let me resend another PR for 4.19-rc and Cc stable@
--
<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] 10+ messages in thread
* [PATCH] clocksource/drivers/timer-atmel-pit: properly handle error cases
@ 2018-09-27 10:00 ` Daniel Lezcano
0 siblings, 0 replies; 10+ messages in thread
From: Daniel Lezcano @ 2018-09-27 10:00 UTC (permalink / raw)
To: linux-arm-kernel
On 26/09/2018 14:38, Nicolas Ferre wrote:
> Daniel,
>
> On 01/05/2018 at 10:36, Daniel Lezcano wrote:
>> On Wed, Apr 25, 2018 at 12:14:39PM +0200, Alexandre Belloni wrote:
>>> smatch now reports a possible leak:
>>>
>>> smatch warnings:
>>> drivers/clocksource/timer-atmel-pit.c:183 at91sam926x_pit_dt_init()
>>> warn: possible memory leak of 'data'
>>>
>>> Ensure data is freed before exiting with an error.
>>>
>>> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>>> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
>>> ---
>>
>> Applied for 4.17-rc
>
> We don't see it in Mainline as of 4.19-rc neither in linux-next. Has it
> been forgotten?
Yes, my bad. I thought it was merge in tip:timers/urgent
Let me resend another PR for 4.19-rc and Cc stable@
--
<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] 10+ messages in thread
* [PATCH] clocksource/drivers/timer-atmel-pit: Properly handle error cases
2018-09-27 14:48 [GIT PULL] clocksource 4.19 fix-2 Daniel Lezcano
@ 2018-09-27 14:51 ` Daniel Lezcano
0 siblings, 0 replies; 10+ messages in thread
From: Daniel Lezcano @ 2018-09-27 14:51 UTC (permalink / raw)
To: tglx
Cc: mingo, Alexandre Belloni, stable, Dan Carpenter, Nicolas Ferre,
open list:CLOCKSOURCE, CLOCKEVENT DRIVERS,
moderated list:ARM/Microchip (AT91) SoC support
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
The smatch utility reports a possible leak:
smatch warnings:
drivers/clocksource/timer-atmel-pit.c:183 at91sam926x_pit_dt_init() warn: possible memory leak of 'data'
Ensure data is freed before exiting with an error.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: stable@vger.kernel.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/clocksource/timer-atmel-pit.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index ec8a437..2fab18f 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -180,26 +180,29 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
data->base = of_iomap(node, 0);
if (!data->base) {
pr_err("Could not map PIT address\n");
- return -ENXIO;
+ ret = -ENXIO;
+ goto exit;
}
data->mck = of_clk_get(node, 0);
if (IS_ERR(data->mck)) {
pr_err("Unable to get mck clk\n");
- return PTR_ERR(data->mck);
+ ret = PTR_ERR(data->mck);
+ goto exit;
}
ret = clk_prepare_enable(data->mck);
if (ret) {
pr_err("Unable to enable mck\n");
- return ret;
+ goto exit;
}
/* Get the interrupts property */
data->irq = irq_of_parse_and_map(node, 0);
if (!data->irq) {
pr_err("Unable to get IRQ from DT\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto exit;
}
/*
@@ -227,7 +230,7 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
ret = clocksource_register_hz(&data->clksrc, pit_rate);
if (ret) {
pr_err("Failed to register clocksource\n");
- return ret;
+ goto exit;
}
/* Set up irq handler */
@@ -236,7 +239,8 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
"at91_tick", data);
if (ret) {
pr_err("Unable to setup IRQ\n");
- return ret;
+ clocksource_unregister(&data->clksrc);
+ goto exit;
}
/* Set up and register clockevents */
@@ -254,6 +258,10 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
clockevents_register_device(&data->clkevt);
return 0;
+
+exit:
+ kfree(data);
+ return ret;
}
TIMER_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit",
at91sam926x_pit_dt_init);
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH] clocksource/drivers/timer-atmel-pit: Properly handle error cases
@ 2018-09-27 14:51 ` Daniel Lezcano
0 siblings, 0 replies; 10+ messages in thread
From: Daniel Lezcano @ 2018-09-27 14:51 UTC (permalink / raw)
To: linux-arm-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
The smatch utility reports a possible leak:
smatch warnings:
drivers/clocksource/timer-atmel-pit.c:183 at91sam926x_pit_dt_init() warn: possible memory leak of 'data'
Ensure data is freed before exiting with an error.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: stable at vger.kernel.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/clocksource/timer-atmel-pit.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index ec8a437..2fab18f 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -180,26 +180,29 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
data->base = of_iomap(node, 0);
if (!data->base) {
pr_err("Could not map PIT address\n");
- return -ENXIO;
+ ret = -ENXIO;
+ goto exit;
}
data->mck = of_clk_get(node, 0);
if (IS_ERR(data->mck)) {
pr_err("Unable to get mck clk\n");
- return PTR_ERR(data->mck);
+ ret = PTR_ERR(data->mck);
+ goto exit;
}
ret = clk_prepare_enable(data->mck);
if (ret) {
pr_err("Unable to enable mck\n");
- return ret;
+ goto exit;
}
/* Get the interrupts property */
data->irq = irq_of_parse_and_map(node, 0);
if (!data->irq) {
pr_err("Unable to get IRQ from DT\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto exit;
}
/*
@@ -227,7 +230,7 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
ret = clocksource_register_hz(&data->clksrc, pit_rate);
if (ret) {
pr_err("Failed to register clocksource\n");
- return ret;
+ goto exit;
}
/* Set up irq handler */
@@ -236,7 +239,8 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
"at91_tick", data);
if (ret) {
pr_err("Unable to setup IRQ\n");
- return ret;
+ clocksource_unregister(&data->clksrc);
+ goto exit;
}
/* Set up and register clockevents */
@@ -254,6 +258,10 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
clockevents_register_device(&data->clkevt);
return 0;
+
+exit:
+ kfree(data);
+ return ret;
}
TIMER_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit",
at91sam926x_pit_dt_init);
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2018-09-27 14:51 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-25 10:14 [PATCH] clocksource/drivers/timer-atmel-pit: properly handle error cases Alexandre Belloni
2018-04-25 10:14 ` Alexandre Belloni
2018-05-01 8:36 ` Daniel Lezcano
2018-05-01 8:36 ` Daniel Lezcano
2018-09-26 12:38 ` Nicolas Ferre
2018-09-26 12:38 ` Nicolas Ferre
2018-09-27 10:00 ` Daniel Lezcano
2018-09-27 10:00 ` Daniel Lezcano
2018-09-27 14:48 [GIT PULL] clocksource 4.19 fix-2 Daniel Lezcano
2018-09-27 14:51 ` [PATCH] clocksource/drivers/timer-atmel-pit: Properly handle error cases Daniel Lezcano
2018-09-27 14:51 ` Daniel Lezcano
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.