[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200520120054.GB172354@mwanda>
Date: Wed, 20 May 2020 15:00:54 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Alex Deucher <alexander.deucher@....com>,
Kevin Wang <kevin1.wang@....com>
Cc: Christian König <christian.koenig@....com>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>, Evan Quan <evan.quan@....com>,
Rui Huang <ray.huang@....com>,
Kenneth Feng <kenneth.feng@....com>,
Yintian Tao <yttao@....com>,
Hawking Zhang <Hawking.Zhang@....com>,
amd-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: [PATCH] drm/amdgpu: off by on 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: 4e01847c38f7 ("drm/amdgpu: optimize amdgpu device attribute code")
Signed-off-by: Dan Carpenter <dan.carpenter@...cle.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index b75362bf0742..ee4a8e44fbeb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -1931,7 +1931,7 @@ static int amdgpu_device_attr_create_groups(struct amdgpu_device *adev,
uint32_t mask)
{
int ret = 0;
- uint32_t i = 0;
+ int i;
for (i = 0; i < counts; i++) {
ret = amdgpu_device_attr_create(adev, &attrs[i], mask);
@@ -1942,9 +1942,8 @@ static int amdgpu_device_attr_create_groups(struct amdgpu_device *adev,
return 0;
failed:
- for (; i > 0; i--) {
+ while (--i >= 0)
amdgpu_device_attr_remove(adev, &attrs[i]);
- }
return ret;
}
--
2.26.2
Powered by blists - more mailing lists