public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] irqchip/tango: Fix possible null ptr reference in tangox_irq_init
@ 2020-09-03  1:59 Ye Bin
  2020-09-03  8:10 ` Marc Zyngier
  0 siblings, 1 reply; 2+ messages in thread
From: Ye Bin @ 2020-09-03  1:59 UTC (permalink / raw)
  To: tglx, jason, maz, linux-kernel; +Cc: Ye Bin

In tangox_irq_init allocate chip but not test.

Signed-off-by: Ye Bin <yebin10@huawei.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 34290f09b853..25da120230ad 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)
+		panic("%pOFn: failed to get chip", node);
 	chip->ctl = res.start - baseres->start;
 	chip->base = base;
 
-- 
2.25.4


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

* Re: [PATCH] irqchip/tango: Fix possible null ptr reference in tangox_irq_init
  2020-09-03  1:59 [PATCH] irqchip/tango: Fix possible null ptr reference in tangox_irq_init Ye Bin
@ 2020-09-03  8:10 ` Marc Zyngier
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Zyngier @ 2020-09-03  8:10 UTC (permalink / raw)
  To: Ye Bin; +Cc: tglx, jason, linux-kernel

On 2020-09-03 02:59, Ye Bin wrote:
> In tangox_irq_init allocate chip but not test.
> 
> Signed-off-by: Ye Bin <yebin10@huawei.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 34290f09b853..25da120230ad 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)
> +		panic("%pOFn: failed to get chip", node);
>  	chip->ctl = res.start - baseres->start;
>  	chip->base = base;

So you are trading a panic for a panic? What is the point?
A failing kzalloc already gives you all the information you may
need.

         M.
-- 
Jazz is not dead. It just smells funny...

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

end of thread, other threads:[~2020-09-03  8:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-03  1:59 [PATCH] irqchip/tango: Fix possible null ptr reference in tangox_irq_init Ye Bin
2020-09-03  8:10 ` Marc Zyngier

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