* [PATCH] irqchip/tango: Add NULL check after memory operation
@ 2019-07-21 18:15 Hariprasad Kelam
2019-07-22 8:54 ` Måns Rullgård
0 siblings, 1 reply; 2+ messages in thread
From: Hariprasad Kelam @ 2019-07-21 18:15 UTC (permalink / raw)
To: Thomas Gleixner, Jason Cooper, Marc Zyngier, Marc Gonzalez,
Mans Rullgard, linux-kernel, linux-arm-kernel
Add NULL check after kzalloc operation.
Fix below issue reported by coccicheck
./drivers/irqchip/irq-tango.c:189:1-5: alloc with no test, possible
model on line 193
Signed-off-by: Hariprasad Kelam <hariprasad.kelam@gmail.com>
---
drivers/irqchip/irq-tango.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/irqchip/irq-tango.c b/drivers/irqchip/irq-tango.c
index 34290f0..761b9fa 100644
--- a/drivers/irqchip/irq-tango.c
+++ b/drivers/irqchip/irq-tango.c
@@ -187,6 +187,8 @@ static int __init tangox_irq_init(void __iomem *base, struct resource *baseres,
panic("%pOFn: failed to get address", node);
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
+ if (!chip)
+ return -ENOMEM;
chip->ctl = res.start - baseres->start;
chip->base = base;
--
2.7.4
_______________________________________________
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] 2+ messages in thread
* Re: [PATCH] irqchip/tango: Add NULL check after memory operation
2019-07-21 18:15 [PATCH] irqchip/tango: Add NULL check after memory operation Hariprasad Kelam
@ 2019-07-22 8:54 ` Måns Rullgård
0 siblings, 0 replies; 2+ messages in thread
From: Måns Rullgård @ 2019-07-22 8:54 UTC (permalink / raw)
To: Hariprasad Kelam
Cc: Jason Cooper, Marc Gonzalez, Marc Zyngier, linux-kernel,
Thomas Gleixner, linux-arm-kernel
Hariprasad Kelam <hariprasad.kelam@gmail.com> writes:
> Add NULL check after kzalloc operation.
>
> Fix below issue reported by coccicheck
> ./drivers/irqchip/irq-tango.c:189:1-5: alloc with no test, possible
> model on line 193
>
> Signed-off-by: Hariprasad Kelam <hariprasad.kelam@gmail.com>
> ---
> drivers/irqchip/irq-tango.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/irqchip/irq-tango.c b/drivers/irqchip/irq-tango.c
> index 34290f0..761b9fa 100644
> --- a/drivers/irqchip/irq-tango.c
> +++ b/drivers/irqchip/irq-tango.c
> @@ -187,6 +187,8 @@ static int __init tangox_irq_init(void __iomem *base, struct resource *baseres,
> panic("%pOFn: failed to get address", node);
>
> chip = kzalloc(sizeof(*chip), GFP_KERNEL);
> + if (!chip)
> + return -ENOMEM;
> chip->ctl = res.start - baseres->start;
> chip->base = base;
>
> --
Nothing checks the return value of that function, so bad things will
still happen, only more confusing to debug. If you really want to
"fix" this, you should either:
- Simply panic() like the other error cases. If anything here fails,
the system will not work anyway.
- Replace the panic() calls with error returns and check the return
value in tangox_of_irq_init(). The system will still end up unusable.
--
Måns Rullgård
_______________________________________________
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] 2+ messages in thread
end of thread, other threads:[~2019-07-22 8:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-21 18:15 [PATCH] irqchip/tango: Add NULL check after memory operation Hariprasad Kelam
2019-07-22 8:54 ` Måns Rullgård
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).