irqchip/loongson-htvec:- Handle return value of ioremap.
Subsystems (3)
PATCH 1/1 irqchip/loongson-htvec:- Handle return value of ioremap.
From: zhaoxiao <[email protected]>
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.
--- drivers/irqchip/irq-loongson-htvec.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/irqchip/irq-loongson-htvec.c +3 -0
@@ -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 ;
Signature · 1 line
2.20.1
Quoted 34 lines · zhaoxiao
From: zhaoxiao <[email protected]>
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 <[email protected]>--- drivers/irqchip/irq-loongson-htvec.c | 3 +++ 1 file changed, 3 insertions(+)drivers/irqchip/irq-loongson-htvec.c +2
-0@@ -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 */ drivers/irqchip/irq-loongson-htvec.c +1
-0for (i =0 ; i < priv->num_parents; i++)@@ -307,6 +309,7 @@ struct fwnode_handle *htvec_acpi_init(structfwnode_handle *parent, iounmap_base: iounmap(priv->base); priv->domain_handle =NULL ; +free_priv:kfree (priv);
Quoted 1 line
return NULL;
What is the difference between this and the patch you sent 3 days ago?
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Quoted 26 lines · zhaoxiao
From: zhaoxiao <[email protected]>
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 <[email protected]>--- drivers/irqchip/irq-loongson-htvec.c | 3 +++ 1 file changed, 3 insertions(+)drivers/irqchip/irq-loongson-htvec.c +2
-0@@ -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++)
drivers/irqchip/irq-loongson-htvec.c struct fwnode_handle *htvec_acpi_init(struct fwnode_handle *parent, · line 315
Quoted 7 lines
drivers/irqchip/irq-loongson-htvec.c +1
-0@@ -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.
Signature · 1 line
Without deviation from the norm, progress is not possible.