On Thu, Sep 24, 2026 at 12:00:10PM +0530, Jyoti Gupta wrote:
> mpic_alloc() allocates struct mpic (and optionally the protected
> sources bitmap) but does not free them when mpic_setup_error_int() or
> irq_domain_create_linear() fails, leaking the memory.
> 
> Initialise mpic to NULL and free the bitmap and the mpic in the common
> error path before dropping the device node reference. The register
> mappings are not released here.
> 
> Signed-off-by: Jyoti Gupta <[email protected]>
> ---
>  arch/powerpc/sysdev/mpic.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
> index 6e8fa94985f3..e777b33f170d 100644
> --- a/arch/powerpc/sysdev/mpic.c
> +++ b/arch/powerpc/sysdev/mpic.c
> @@ -1221,7 +1221,7 @@ struct mpic * __init mpic_alloc(struct device_node 
> *node,
>                               const char *name)
>  {
>       int i, psize, intvec_top;
> -     struct mpic *mpic;
> +     struct mpic *mpic = NULL;
We don't need this initialization. We initialize it later again.
>       u32 greg_feature;
>       const char *vers;
>       const u32 *psrc;
> @@ -1488,10 +1488,6 @@ struct mpic * __init mpic_alloc(struct device_node 
> *node,
>                                                intvec_top,
>                                                &mpic_host_ops, mpic);
>  
> -     /*
> -      * FIXME: The code leaks the MPIC object and mappings here; this
> -      * is very unlikely to fail but it ought to be fixed anyways.
> -      */
>       if (mpic->irqhost == NULL)
>               goto err_of_node_put;
>  
> @@ -1527,6 +1523,9 @@ struct mpic * __init mpic_alloc(struct device_node 
> *node,
>       return mpic;
>  
>  err_of_node_put:
> +     if (mpic)
> +             bitmap_free(mpic->protected);
> +     kfree(mpic);
>       of_node_put(node);
>       return NULL;
>  }
> -- 
> 2.55.0
> 
> 
Do we need a fixes tag for this?

Regards,
Mukesh

Reply via email to