Re: [PATCH] powerpc/perf: vpa-dtl: fix resource leak on allocation failure

From: mdshahid03

Date: Tue Nov 17 2026 - 22:57:21 EST


Hi,

Could you please check this patch and give your feedback,when
time permits.

Thanks
Shahid.

On 2026-11-12 19:14 +0530, mdshahid03@xxxxxxxxx wrote:
> From: Mohammad Shahid <mdshahid03@xxxxxxxxx>
>
> 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@xxxxxxxxx>
> ---
> 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
>
>
>