public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Yejune Deng <yejune.deng@gmail.com>
Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] irqchip/gic: add WARN_ON() to facilitate backtracking
Date: Tue, 29 Dec 2020 09:27:40 +0000	[thread overview]
Message-ID: <36538faa77fd0e34f559ec547b983c72@kernel.org> (raw)
In-Reply-To: <1609226114-32933-1-git-send-email-yejune.deng@gmail.com>

Yejune,

On 2020-12-29 07:15, Yejune Deng wrote:
> There is two function gic_of_init() and gic_of_init_child() called
> gic_of_setup(),so add WARN_ON() to facilitate backtracking.
> 
> Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
> ---
>  drivers/irqchip/irq-gic.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
> index b1d9c22..7c11705 100644
> --- a/drivers/irqchip/irq-gic.c
> +++ b/drivers/irqchip/irq-gic.c
> @@ -1380,7 +1380,7 @@ static bool gic_check_eoimode(struct device_node
> *node, void __iomem **base)
> 
>  static int gic_of_setup(struct gic_chip_data *gic, struct device_node 
> *node)
>  {
> -	if (!gic || !node)
> +	if (WARN_ON(!gic || !node))
>  		return -EINVAL;
> 
>  	gic->raw_dist_base = of_iomap(node, 0);

I don't immediately see what you gain with this. If you end-up here
with NULL pointers, that either because:

- you have failed to allocate the GIC private data structure:
   but as it turns out, these allocations either cannot fail (gic_data[]
   is static), or the dynamic allocation in gic_of_init_child() is 
already
   checked.

- node is NULL: both paths already check for a NULL node, so that cannot
   fail either.

My conclusion is that these checks can never trigger, and we should be
able to *remove* them altogether.

Am I missing something?

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

  reply	other threads:[~2020-12-29  9:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-29  7:15 [PATCH] irqchip/gic: add WARN_ON() to facilitate backtracking Yejune Deng
2020-12-29  9:27 ` Marc Zyngier [this message]
2020-12-30  2:16   ` Yejune Deng

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=36538faa77fd0e34f559ec547b983c72@kernel.org \
    --to=maz@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=yejune.deng@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox