All of lore.kernel.org
 help / color / mirror / Atom feed
From: mdshahid03@gmail.com
To: maddy@linux.ibm.com
Cc: mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org,
	ritesh.list@gmail.com, sshegde@linux.ibm.com,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	Mohammad Shahid <mdshahid03@gmail.com>
Subject: [PATCH] powerpc/perf: vpa-dtl: fix resource leak on allocation failure
Date: Thu, 12 Nov 2026 19:14:55 +0530	[thread overview]
Message-ID: <20261112134455.6880-1-mdshahid03@gmail.com> (raw)

From: Mohammad Shahid <mdshahid03@gmail.com>

vpa_dtl_event_init acquires dtl_access_lock when initializing the
first vpa_dtl PMU event.

If vpa_dtl_mem_alloc() fails,the function returns -ENOMEM without
releasing the semaphore.

Release the semaphore when buffer allocation fails and no other
PMU events are active.

Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>
---
 arch/powerpc/perf/vpa-dtl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/powerpc/perf/vpa-dtl.c b/arch/powerpc/perf/vpa-dtl.c
index 3e3d65b6c796..20eafeaffa6b 100644
--- a/arch/powerpc/perf/vpa-dtl.c
+++ b/arch/powerpc/perf/vpa-dtl.c
@@ -396,6 +396,8 @@ static int vpa_dtl_event_init(struct perf_event *event)
 
 	/* Allocate dtl buffer memory */
 	if (vpa_dtl_mem_alloc(event->cpu)) {
+		if (dtl_global_refc == 0)
+			up_write(&dtl_access_lock);
 		spin_unlock(&dtl_global_lock);
 		return -ENOMEM;
 	}
-- 
2.43.0



             reply	other threads:[~2026-11-12 13:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 13:44 mdshahid03 [this message]
2026-11-18  3:56 ` [PATCH] powerpc/perf: vpa-dtl: fix resource leak on allocation failure mdshahid03
2026-11-18 11:32 ` Ritesh Harjani

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=20261112134455.6880-1-mdshahid03@gmail.com \
    --to=mdshahid03@gmail.com \
    --cc=chleroy@kernel.org \
    --cc=linux-kernel@vger.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=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.