From: Dan Carpenter Date: Wed, 20 May 2020 15:25:56 +0000 (+0300) Subject: drm/amdgpu: off by one in amdgpu_device_attr_create_groups() error handling X-Git-Tag: baikal/mips/sdk5.9~13559^2^2~14 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=e07c9ad6f6b995341096da76fac96ca20bbed1fd;p=kernel.git drm/amdgpu: off by one in amdgpu_device_attr_create_groups() error handling This loop in the error handling code should start a "i - 1" and end at "i == 0". Currently it starts a "i" and ends at "i == 1". The result is that it removes one attribute that wasn't created yet, and leaks the zeroeth attribute. Fixes: fd82912b0ae0 ("drm/amdgpu: optimize amdgpu device attribute code") Acked-by: Michael J. Ruhl Reviewed-by: Christian König Reviewed-by: Kevin Wang Signed-off-by: Dan Carpenter Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c index bc7de2f62d121..17bc7f530898b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c @@ -1837,9 +1837,8 @@ static int amdgpu_device_attr_create_groups(struct amdgpu_device *adev, return 0; failed: - for (; i > 0; i--) { + while (i--) amdgpu_device_attr_remove(adev, &attrs[i]); - } return ret; }