From: Mohammad Shahid <[email protected]>

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 <[email protected]>
---
 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 via email to