]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
drm/panfrost: perfcnt: fix ref count leak in panfrost_perfcnt_enable_locked
authorNavid Emamdoost <navid.emamdoost@gmail.com>
Sun, 14 Jun 2020 06:36:19 +0000 (01:36 -0500)
committerRob Herring <robh@kernel.org>
Fri, 7 Aug 2020 16:45:07 +0000 (10:45 -0600)
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 <alyssa.rosenzweig@collabora.com>
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200614063619.44944-1-navid.emamdoost@gmail.com
drivers/gpu/drm/panfrost/panfrost_perfcnt.c

index ec4695cf3caf315b56c02c37e334457719f262f8..fdbc8d94913562339137b4ef7876842507e1d9aa 100644 (file)
@@ -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);
@@ -168,6 +170,8 @@ err_close_bo:
        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;
 }