linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: zhaoxiao <long870912@gmail.com>
Cc: chenhuacai@kernel.org, jiaxun.yang@flygoat.com,
	tglx@linutronix.de, linux-mips@vger.kernel.org,
	linux-kernel@vger.kernel.org, zhaoxiao <zhaoxiao@uniontech.com>
Subject: Re: [PATCH] irqchip/loongson-htvec:- Handle return value of ioremap.
Date: Thu, 21 Oct 2021 10:23:02 +0100	[thread overview]
Message-ID: <87sfwubukp.wl-maz@kernel.org> (raw)
In-Reply-To: <20211015072523.30615-1-long870912@gmail.com>

On Fri, 15 Oct 2021 08:25:23 +0100,
zhaoxiao <long870912@gmail.com> wrote:
> 
> From: zhaoxiao <zhaoxiao@uniontech.com>
> 
> Here, If ioremap will fail. It will return NULL.Kernel can run into
> a NULL-pointer dereference. This error check will avoid NULL pointer
> dereference.
> 
> Signed-off-by: zhaoxiao <zhaoxiao@uniontech.com>
> ---
>  drivers/irqchip/irq-loongson-htvec.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/irqchip/irq-loongson-htvec.c b/drivers/irqchip/irq-loongson-htvec.c
> index 1cc0bceb4472..a36c20f44ec4 100644
> --- a/drivers/irqchip/irq-loongson-htvec.c
> +++ b/drivers/irqchip/irq-loongson-htvec.c
> @@ -267,6 +267,8 @@ struct fwnode_handle *htvec_acpi_init(struct fwnode_handle *parent,
>  
>  	priv->num_parents = HTVEC_MAX_PARENT_IRQ;
>  	priv->base = ioremap(acpi_htvec->address, acpi_htvec->size);
> +	if (!priv->base)
> +		goto free_priv;
>  
>  	/* Interrupt may come from any of the 8 interrupt lines */
>  	for (i = 0; i < priv->num_parents; i++)
> @@ -307,6 +309,7 @@ struct fwnode_handle *htvec_acpi_init(struct fwnode_handle *parent,
>  iounmap_base:
>  	iounmap(priv->base);
>  	priv->domain_handle = NULL;
> +free_priv:
>  	kfree(priv);
>  
>  	return NULL;

I have no idea what code base this patch is against, but certainly not
any upstream kernel. There is no trace of any ACPI support in this
driver.

Please only send patches that make sense for upstream.

	M.

-- 
Without deviation from the norm, progress is not possible.

      parent reply	other threads:[~2021-10-21  9:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15  7:25 [PATCH] irqchip/loongson-htvec:- Handle return value of ioremap zhaoxiao
2021-10-15  9:24 ` Marc Zyngier
2021-10-21  9:23 ` Marc Zyngier [this message]

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=87sfwubukp.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=jiaxun.yang@flygoat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=long870912@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=zhaoxiao@uniontech.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;
as well as URLs for NNTP newsgroup(s).