Fix memory leak in amdgpu_debugfs_gpr_read not freeing data when
pm_runtime_get_sync failed.
Fixes: a9ffe2a983383 ("drm/amdgpu/debugfs: properly handle runtime pm")
Signed-off-by: Chen Tao <[email protected]>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
index 1a4894fa3693..bea8c36a53a4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
@@ -862,8 +862,10 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf,
return -ENOMEM;
r = pm_runtime_get_sync(adev->ddev->dev);
- if (r < 0)
+ if (r < 0) {
+ kfree(data);
return r;
+ }
r = amdgpu_virt_enable_access_debugfs(adev);
if (r < 0)
--
2.22.0
Fix memory leak in amdgpu_debugfs_gpr_read not freeing data when
amdgpu_virt_enable_access_debugfs failed.
Fixes: 95a2f917387a2 ("drm/amdgpu: restrict debugfs register accessunder SR-IOV")
Signed-off-by: Chen Tao <[email protected]>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
index bea8c36a53a4..f66ee4b8f04e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
@@ -868,8 +868,10 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf,
}
r = amdgpu_virt_enable_access_debugfs(adev);
- if (r < 0)
+ if (r < 0) {
+ kfree(data);
return r;
+ }
/* switch to the specific se/sh/cu */
mutex_lock(&adev->grbm_idx_mutex);
--
2.22.0
Am 16.06.20 um 08:30 schrieb Chen Tao:
> Fix memory leak in amdgpu_debugfs_gpr_read not freeing data when
> pm_runtime_get_sync failed.
>
> Fixes: a9ffe2a983383 ("drm/amdgpu/debugfs: properly handle runtime pm")
> Signed-off-by: Chen Tao <[email protected]>
Probably better to remove the duplication of result and r here and then
use "goto err".
Regards,
Christian
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> index 1a4894fa3693..bea8c36a53a4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> @@ -862,8 +862,10 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf,
> return -ENOMEM;
>
> r = pm_runtime_get_sync(adev->ddev->dev);
> - if (r < 0)
> + if (r < 0) {
> + kfree(data);
> return r;
> + }
>
> r = amdgpu_virt_enable_access_debugfs(adev);
> if (r < 0)
Ok, i will modify it in v2 patch.
On 2020/6/16 14:50, Christian König wrote:
> Probably better to remove the duplication of result and r here and
> then use "goto err".
> Fix memory leak in amdgpu_debugfs_gpr_read not freeing data when
> pm_runtime_get_sync failed.
* Would you like to improve the exception handling any more for this software module?
* How do you think about calling the function “pm_runtime_put_noidle”?
Regards,
Markus