diff mbox

[v1,1/2] xen/arm: vgic: Check for vgic handler to be initialized before dereferencing it

Message ID 1503941546-24716-2-git-send-email-olekstysh@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Oleksandr Tyshchenko Aug. 28, 2017, 5:32 p.m. UTC
From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

Since domain_vgic_free() can be called when the vgic_ops haven't been
initialised yet, always check that d->arch.vgic.handler is not a null.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
---
 xen/arch/arm/vgic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Stefano Stabellini Sept. 15, 2017, 9:24 p.m. UTC | #1
On Mon, 28 Aug 2017, Oleksandr Tyshchenko wrote:
> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
> 
> Since domain_vgic_free() can be called when the vgic_ops haven't been
> initialised yet, always check that d->arch.vgic.handler is not a null.
> 
> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

There is a code style problem, but I'll fix on commit.

Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
>  xen/arch/arm/vgic.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
> index 7a4e3cd..6cf947c 100644
> --- a/xen/arch/arm/vgic.c
> +++ b/xen/arch/arm/vgic.c
> @@ -187,7 +187,8 @@ void domain_vgic_free(struct domain *d)
>          }
>      }
>  
> -    d->arch.vgic.handler->domain_free(d);
> +    if ( d->arch.vgic.handler )
> +       d->arch.vgic.handler->domain_free(d);
>      xfree(d->arch.vgic.shared_irqs);
>      xfree(d->arch.vgic.pending_irqs);
>      xfree(d->arch.vgic.allocated_irqs);
> -- 
> 2.7.4
>
diff mbox

Patch

diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index 7a4e3cd..6cf947c 100644
--- a/xen/arch/arm/vgic.c
+++ b/xen/arch/arm/vgic.c
@@ -187,7 +187,8 @@  void domain_vgic_free(struct domain *d)
         }
     }
 
-    d->arch.vgic.handler->domain_free(d);
+    if ( d->arch.vgic.handler )
+       d->arch.vgic.handler->domain_free(d);
     xfree(d->arch.vgic.shared_irqs);
     xfree(d->arch.vgic.pending_irqs);
     xfree(d->arch.vgic.allocated_irqs);