Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1554135 > unrolled thread
| Started by | Arvind Yadav <arvind.yadav.cs@gmail.com> |
|---|---|
| First post | 2017-01-09 09:10 +0100 |
| Last post | 2017-01-09 10:10 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v1] irqchip: irq-mips-gic:- Handle return NULL error from ioremap_nocache Arvind Yadav <arvind.yadav.cs@gmail.com> - 2017-01-09 09:10 +0100
Re: [PATCH v1] irqchip: irq-mips-gic:- Handle return NULL error from ioremap_nocache Marc Zyngier <marc.zyngier@arm.com> - 2017-01-09 10:10 +0100
| From | Arvind Yadav <arvind.yadav.cs@gmail.com> |
|---|---|
| Date | 2017-01-09 09:10 +0100 |
| Subject | [PATCH v1] irqchip: irq-mips-gic:- Handle return NULL error from ioremap_nocache |
| Message-ID | <sXDbH-1Ae-1@gated-at.bofh.it> |
Here, If ioremap_nocache 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: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
drivers/irqchip/irq-mips-gic.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c
index c01c09e..eeea2e8 100644
--- a/drivers/irqchip/irq-mips-gic.c
+++ b/drivers/irqchip/irq-mips-gic.c
@@ -979,6 +979,8 @@ static void __init __gic_init(unsigned long gic_base_addr,
__gic_base_addr = gic_base_addr;
gic_base = ioremap_nocache(gic_base_addr, gic_addrspace_size);
+ if (!gic_base)
+ panic("Failed to map GIC memory");
gicconfig = gic_read(GIC_REG(SHARED, GIC_SH_CONFIG));
gic_shared_intrs = (gicconfig & GIC_SH_CONFIG_NUMINTRS_MSK) >>
--
1.9.1
[toc] | [next] | [standalone]
| From | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| Date | 2017-01-09 10:10 +0100 |
| Subject | Re: [PATCH v1] irqchip: irq-mips-gic:- Handle return NULL error from ioremap_nocache |
| Message-ID | <sXE7M-2dw-23@gated-at.bofh.it> |
| In reply to | #1554135 |
On 09/01/17 08:08, Arvind Yadav wrote:
> Here, If ioremap_nocache 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: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
> drivers/irqchip/irq-mips-gic.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c
> index c01c09e..eeea2e8 100644
> --- a/drivers/irqchip/irq-mips-gic.c
> +++ b/drivers/irqchip/irq-mips-gic.c
> @@ -979,6 +979,8 @@ static void __init __gic_init(unsigned long gic_base_addr,
> __gic_base_addr = gic_base_addr;
>
> gic_base = ioremap_nocache(gic_base_addr, gic_addrspace_size);
> + if (!gic_base)
> + panic("Failed to map GIC memory");
So you're replacing a panic due to dereferencing a NULL pointer with
another panic -- not much progress here. I appreciate that the message
is a bit more explicit, but is there something slightly less drastic we
could do? Like returning an error code and see if the kernel otherwise
recovers (possibly with reduced functionality)?
>
> gicconfig = gic_read(GIC_REG(SHARED, GIC_SH_CONFIG));
> gic_shared_intrs = (gicconfig & GIC_SH_CONFIG_NUMINTRS_MSK) >>
>
Thanks,
M.
--
Jazz is not dead. It just smells funny...
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web