All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] irqchip/loongson-htvec:- Handle return value of ioremap.
@ 2021-10-15  7:25 zhaoxiao
  2021-10-15  9:24 ` Marc Zyngier
  2021-10-21  9:23 ` Marc Zyngier
  0 siblings, 2 replies; 3+ messages in thread
From: zhaoxiao @ 2021-10-15  7:25 UTC (permalink / raw)
  To: chenhuacai, jiaxun.yang, tglx, maz; +Cc: linux-mips, linux-kernel, zhaoxiao

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;
-- 
2.20.1


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

* Re: [PATCH] irqchip/loongson-htvec:- Handle return value of ioremap.
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Marc Zyngier @ 2021-10-15  9:24 UTC (permalink / raw)
  To: zhaoxiao
  Cc: chenhuacai, jiaxun.yang, tglx, linux-mips, linux-kernel, zhaoxiao

On 2021-10-15 08:25, zhaoxiao 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;

What is the difference between this and the patch you sent 3 days ago?

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

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

* Re: [PATCH] irqchip/loongson-htvec:- Handle return value of ioremap.
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Marc Zyngier @ 2021-10-21  9:23 UTC (permalink / raw)
  To: zhaoxiao
  Cc: chenhuacai, jiaxun.yang, tglx, linux-mips, linux-kernel, zhaoxiao

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.

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

end of thread, other threads:[~2021-10-21  9:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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.