From: Tom St Denis Date: Thu, 25 Aug 2016 16:16:24 +0000 (-0400) Subject: drm/amd/amdgpu: Fix memleak in cz_parse_power_table() X-Git-Tag: v4.9-rc1~41^2~26^2~140 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=cc945ce3ab563d7dd7657510e1990f6f606c9b46;p=karo-tx-linux.git drm/amd/amdgpu: Fix memleak in cz_parse_power_table() If one of the entries fails to be allocated then free all of the previous entries before freeing the array which holds their pointers. Signed-off-by: Tom St Denis Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/cz_dpm.c b/drivers/gpu/drm/amd/amdgpu/cz_dpm.c index 794c5f36ca68..9c2ab73a7ae3 100644 --- a/drivers/gpu/drm/amd/amdgpu/cz_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/cz_dpm.c @@ -350,6 +350,8 @@ static int cz_parse_power_table(struct amdgpu_device *adev) ps = kzalloc(sizeof(struct cz_ps), GFP_KERNEL); if (ps == NULL) { + for (j = 0; j < i; j++) + kfree(adev->pm.dpm.ps[j].ps_priv); kfree(adev->pm.dpm.ps); return -ENOMEM; }