Skip to content

Commit

Permalink
drm/panfrost: perfcnt: fix ref count leak in panfrost_perfcnt_enable_…
Browse files Browse the repository at this point in the history
…locked

in panfrost_perfcnt_enable_locked, pm_runtime_get_sync is called which
increments the counter even in case of failure, leading to incorrect
ref count. In case of failure, decrement the ref count before returning.

Acked-by: Alyssa Rosenzweig <[email protected]>
Signed-off-by: Navid Emamdoost <[email protected]>
Signed-off-by: Rob Herring <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
  • Loading branch information
Navidem authored and robherring committed Aug 7, 2020
1 parent fd587ff commit 9df0e0c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/gpu/drm/panfrost/panfrost_perfcnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ static int panfrost_perfcnt_enable_locked(struct panfrost_device *pfdev,

ret = pm_runtime_get_sync(pfdev->dev);
if (ret < 0)
return ret;
goto err_put_pm;

bo = drm_gem_shmem_create(pfdev->ddev, perfcnt->bosize);
if (IS_ERR(bo))
return PTR_ERR(bo);
if (IS_ERR(bo)) {
ret = PTR_ERR(bo);
goto err_put_pm;
}

/* Map the perfcnt buf in the address space attached to file_priv. */
ret = panfrost_gem_open(&bo->base, file_priv);
Expand Down Expand Up @@ -168,6 +170,8 @@ static int panfrost_perfcnt_enable_locked(struct panfrost_device *pfdev,
panfrost_gem_close(&bo->base, file_priv);
err_put_bo:
drm_gem_object_put(&bo->base);
err_put_pm:
pm_runtime_put(pfdev->dev);
return ret;
}

Expand Down

0 comments on commit 9df0e0c

Please sign in to comment.