From: Chen Tao Date: Wed, 17 Jun 2020 10:51:29 +0000 (+0800) Subject: drm/amdgpu/debugfs: fix memory leak when pm_runtime_get_sync failed X-Git-Tag: v5.10.7~1861^2~25^2~77 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3e4aeff36e9212a939290c0ca70d4931c4ad1950;p=platform%2Fkernel%2Flinux-rpi.git drm/amdgpu/debugfs: fix memory leak when pm_runtime_get_sync failed 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 Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c index d33cb34..3d0e8f8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c @@ -937,7 +937,7 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf, r = pm_runtime_get_sync(adev->ddev->dev); if (r < 0) - return r; + goto err; r = amdgpu_virt_enable_access_debugfs(adev); if (r < 0) @@ -967,7 +967,7 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf, value = data[result >> 2]; r = put_user(value, (uint32_t *)buf); if (r) { - result = r; + amdgpu_virt_disable_access_debugfs(adev); goto err; } @@ -976,10 +976,13 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf, size -= 4; } -err: kfree(data); amdgpu_virt_disable_access_debugfs(adev); return result; + +err: + kfree(data); + return r; } /**