All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <marc.zyngier@arm.com>
To: YueHaibing <yuehaibing@huawei.com>
Cc: <tglx@linutronix.de>, <jason@lakedaemon.net>,
	<marc.w.gonzalez@free.fr>, <mans@mansr.com>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH -next] irqchip/tango: Fix potential NULL pointer dereference
Date: Tue, 29 Jan 2019 08:55:41 +0000	[thread overview]
Message-ID: <86a7jjvo4y.wl-marc.zyngier@arm.com> (raw)
In-Reply-To: <20190129080122.20392-1-yuehaibing@huawei.com>

On Tue, 29 Jan 2019 08:01:22 +0000,
YueHaibing <yuehaibing@huawei.com> wrote:
> 
> There is a potential NULL pointer dereference in case kzalloc()
> fails and returns NULL.
> 
> Fixes: 4bba66899ac6 ("irqchip/tango: Add support for Sigma Designs SMP86xx/SMP87xx interrupt controller")
> Signed-off-by: YueHaibing <yuehaibing@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 ae28d86..a63b828 100644
> --- a/drivers/irqchip/irq-tango.c
> +++ b/drivers/irqchip/irq-tango.c
> @@ -191,6 +191,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;
>  

This is a commendable effort, but given that the whole error handling
of this driver is just to simply panic, I have the ugly feeling that
this lack of check is more a feature than a bug... Not that I like it,
but at least it is consistent.

If you're going to change that, I'd recommend you overhaul the whole
thing.

Thanks,

	M.

-- 
Jazz is not dead, it just smell funny.

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <marc.zyngier@arm.com>
To: YueHaibing <yuehaibing@huawei.com>
Cc: mans@mansr.com, jason@lakedaemon.net, marc.w.gonzalez@free.fr,
	linux-kernel@vger.kernel.org, tglx@linutronix.de,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH -next] irqchip/tango: Fix potential NULL pointer dereference
Date: Tue, 29 Jan 2019 08:55:41 +0000	[thread overview]
Message-ID: <86a7jjvo4y.wl-marc.zyngier@arm.com> (raw)
In-Reply-To: <20190129080122.20392-1-yuehaibing@huawei.com>

On Tue, 29 Jan 2019 08:01:22 +0000,
YueHaibing <yuehaibing@huawei.com> wrote:
> 
> There is a potential NULL pointer dereference in case kzalloc()
> fails and returns NULL.
> 
> Fixes: 4bba66899ac6 ("irqchip/tango: Add support for Sigma Designs SMP86xx/SMP87xx interrupt controller")
> Signed-off-by: YueHaibing <yuehaibing@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 ae28d86..a63b828 100644
> --- a/drivers/irqchip/irq-tango.c
> +++ b/drivers/irqchip/irq-tango.c
> @@ -191,6 +191,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;
>  

This is a commendable effort, but given that the whole error handling
of this driver is just to simply panic, I have the ugly feeling that
this lack of check is more a feature than a bug... Not that I like it,
but at least it is consistent.

If you're going to change that, I'd recommend you overhaul the whole
thing.

Thanks,

	M.

-- 
Jazz is not dead, it just smell funny.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-01-29  8:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29  8:01 [PATCH -next] irqchip/tango: Fix potential NULL pointer dereference YueHaibing
2019-01-29  8:01 ` YueHaibing
2019-01-29  8:55 ` Marc Zyngier [this message]
2019-01-29  8:55   ` Marc Zyngier
2019-01-29 12:20   ` Måns Rullgård
2019-01-29 12:20     ` Måns Rullgård
2019-01-30  6:25     ` YueHaibing
2019-01-30  6:25       ` YueHaibing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86a7jjvo4y.wl-marc.zyngier@arm.com \
    --to=marc.zyngier@arm.com \
    --cc=jason@lakedaemon.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mans@mansr.com \
    --cc=marc.w.gonzalez@free.fr \
    --cc=tglx@linutronix.de \
    --cc=yuehaibing@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.