* [PATCH] clocksource/drivers/timer-cadence-ttc: fix a signedness bug in probe()
@ 2023-06-06 8:15 Dan Carpenter
2023-06-06 9:26 ` Michal Simek
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2023-06-06 8:15 UTC (permalink / raw)
To: Michal Simek
Cc: Daniel Lezcano, Thomas Gleixner, linux-arm-kernel, linux-kernel,
kernel-janitors
Make the "irq" variable signed so the error handling can work.
Fixes: e932900a3279 ("arm: zynq: Use standard timer binding")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
From static analysis. Untested. Presumably if probe fails the system
is unbootable so I didn't bother looking at the resource leaks.
drivers/clocksource/timer-cadence-ttc.c:377 ttc_setup_clocksource() warn: 'clk' from clk_prepare_enable() not released on lines: 370.
drivers/clocksource/timer-cadence-ttc.c:466 ttc_setup_clockevent() warn: 'clk' from clk_prepare_enable() not released on lines: 466.
drivers/clocksource/timer-cadence-ttc.c:529 ttc_timer_probe() warn: 'irq' from irq_of_parse_and_map() not released on lines: 508,516,521,525.
drivers/clocksource/timer-cadence-ttc.c:529 ttc_timer_probe() warn: 'timer_baseaddr' from of_iomap() not released on lines: 498,508,516,521,525.
---
drivers/clocksource/timer-cadence-ttc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clocksource/timer-cadence-ttc.c b/drivers/clocksource/timer-cadence-ttc.c
index 4efd0cf3b602d..8ba1f5c2d7992 100644
--- a/drivers/clocksource/timer-cadence-ttc.c
+++ b/drivers/clocksource/timer-cadence-ttc.c
@@ -468,13 +468,13 @@ static int __init ttc_setup_clockevent(struct clk *clk,
static int __init ttc_timer_probe(struct platform_device *pdev)
{
- unsigned int irq;
void __iomem *timer_baseaddr;
struct clk *clk_cs, *clk_ce;
static int initialized;
int clksel, ret;
u32 timer_width = 16;
struct device_node *timer = pdev->dev.of_node;
+ int irq;
if (initialized)
return 0;
--
2.30.2
_______________________________________________
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] 3+ messages in thread
* Re: [PATCH] clocksource/drivers/timer-cadence-ttc: fix a signedness bug in probe()
2023-06-06 8:15 [PATCH] clocksource/drivers/timer-cadence-ttc: fix a signedness bug in probe() Dan Carpenter
@ 2023-06-06 9:26 ` Michal Simek
2023-06-06 9:39 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Michal Simek @ 2023-06-06 9:26 UTC (permalink / raw)
To: Dan Carpenter
Cc: Daniel Lezcano, Thomas Gleixner, linux-arm-kernel, linux-kernel,
kernel-janitors
On 6/6/23 10:15, Dan Carpenter wrote:
> Make the "irq" variable signed so the error handling can work.
urq_of_parse_and_map returns unsigned type.
include/linux/of_irq.h:118:extern unsigned int irq_of_parse_and_map(struct
device_node *node, int index);
instead of this condition should be fixed to
irq = irq_of_parse_and_map(timer, 1);
if (!irq) {
...
>
> Fixes: e932900a3279 ("arm: zynq: Use standard timer binding")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> From static analysis. Untested. Presumably if probe fails the system
> is unbootable so I didn't bother looking at the resource leaks.
In the way how systems with TTC are used today that's correct assumption.
But just to be accurate system can also have different timers which could be
used instead.
Thanks,
Michal
_______________________________________________
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] 3+ messages in thread
* Re: [PATCH] clocksource/drivers/timer-cadence-ttc: fix a signedness bug in probe()
2023-06-06 9:26 ` Michal Simek
@ 2023-06-06 9:39 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2023-06-06 9:39 UTC (permalink / raw)
To: Michal Simek
Cc: Daniel Lezcano, Thomas Gleixner, linux-arm-kernel, linux-kernel,
kernel-janitors
On Tue, Jun 06, 2023 at 11:26:20AM +0200, Michal Simek wrote:
>
>
> On 6/6/23 10:15, Dan Carpenter wrote:
> > Make the "irq" variable signed so the error handling can work.
>
> urq_of_parse_and_map returns unsigned type.
>
Ugh... You're right. This is one of those return zero on error IRQ
functions.
> include/linux/of_irq.h:118:extern unsigned int irq_of_parse_and_map(struct
> device_node *node, int index);
>
> instead of this condition should be fixed to
>
> irq = irq_of_parse_and_map(timer, 1);
> if (!irq) {
> ...
>
Sure. I can resend.
regards,
dan carpenter
_______________________________________________
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] 3+ messages in thread
end of thread, other threads:[~2023-06-06 9:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-06 8:15 [PATCH] clocksource/drivers/timer-cadence-ttc: fix a signedness bug in probe() Dan Carpenter
2023-06-06 9:26 ` Michal Simek
2023-06-06 9:39 ` Dan Carpenter
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).