All of lore.kernel.org
 help / color / mirror / Atom feed
From: jyoti <jyoti@linux.ibm.com>
To: amachhiw@linux.ibm.com
Cc: linuxppc-dev@lists.ozlabs.org, maddy@linux.ibm.com,
	mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org,
	ritesh.list@gmail.com, sshegde@linux.ibm.com,
	sourabhjain@linux.ibm.com
Subject: Re: [PATCH] powerpc/mpic: Fix memory leak of mpic on error paths
Date: Tue, 29 Sep 2026 12:06:51 +0530	[thread overview]
Message-ID: <e3c17fc50f7897b08fbd67a120087467@linux.ibm.com> (raw)
In-Reply-To: <20260924145126.cf1c0ae1-37-amachhiw@linux.ibm.com>

On 2026-09-24 15:05, Amit Machhiwal wrote:
> On 2026/09/24 12:00 PM, 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 <jyoti@linux.ibm.com>
> 
> I see a couple of problems with this patch:
> 
> 1. The patch does not apply.  Both "git apply" and "git am" fail on 
> this patch.
>    I think the context lines around the irq_domain_create_linear() call 
> have
>    tabs converted to spaces, which causes the context match to fail.
> 
>       ❯ git apply
> ./20260924_jyoti_powerpc_mpic_fix_memory_leak_of_mpic_on_error_paths.mbx
> --check --verbose
>       Checking patch arch/powerpc/sysdev/mpic.c...
>       error: while searching for:
>       						 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;
> 
> 
>       error: patch failed: arch/powerpc/sysdev/mpic.c:1488
>       error: arch/powerpc/sysdev/mpic.c: patch does not apply
> 
>    Please regenerate with:
> 
>      git format-patch -1
> 
>    and verify with:
> 
>      git apply --check <patch>
> 
>    before resending.
> 

Noted.I will regenerate with git format-patch -1 and verify with git 
apply --check
before resending as v2.

> 2. The mpic_setup_error_int() leak is not actually fixed.  The commit 
> message
>    says both mpic_setup_error_int() and irq_domain_create_linear() 
> failure paths
>    are fixed, but the former still does a bare return NULL:
> 
>      if (fsl_version >= 0x401) {
>          ret = mpic_setup_error_int(mpic, intvec_top - 13);
>          if (ret)
>              return NULL;   /* <-- still leaks mpic and mpic->protected 
> */
>      }
> 
>    This needs to become:
> 
>          if (ret)
>              goto err_of_node_put;
> 
> Thanks,
> Amit
> 

The mpic_setup_error_int() leak is intentionally left to a separate 
patch already under
  review:
"[PATCH] powerpc: Fix missing of_node_put() calls"
That patch converts the return NULL at line 1392 to goto err_of_node_put 
as part of a
broader of_node_put() fix series. This patch focuses only on the 
irq_domain_create_linear()
failure path.

Thanks,
Jyoti


  reply	other threads:[~2026-09-29  8:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24  6:30 [PATCH] powerpc/mpic: Fix memory leak of mpic on error paths Jyoti Gupta
2026-09-24  9:28 ` Mukesh Kumar Chaurasiya
2026-09-29  6:45   ` jyoti
2026-09-24  9:35 ` Amit Machhiwal
2026-09-29  6:36   ` jyoti [this message]
2026-09-29  7:32   ` Amit Machhiwal
  -- strict thread matches above, loose matches on Subject: below --
2026-09-30 16:41 Jyoti Gupta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e3c17fc50f7897b08fbd67a120087467@linux.ibm.com \
    --to=jyoti@linux.ibm.com \
    --cc=amachhiw@linux.ibm.com \
    --cc=chleroy@kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=ritesh.list@gmail.com \
    --cc=sourabhjain@linux.ibm.com \
    --cc=sshegde@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.