dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: off by on in amdgpu_device_attr_create_groups() error handling
@ 2020-05-20 12:00 Dan Carpenter
  2020-05-20 12:05 ` Christian König
  0 siblings, 1 reply; 10+ messages in thread
From: Dan Carpenter @ 2020-05-20 12:00 UTC (permalink / raw)
  To: Alex Deucher, Kevin Wang
  Cc: David Airlie, kernel-janitors, linux-kernel, amd-gfx,
	Hawking Zhang, Rui Huang, dri-devel, Evan Quan, Kenneth Feng,
	Christian König, Yintian Tao

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@oracle.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

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-05-20 18:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20 12:00 [PATCH] drm/amdgpu: off by on in amdgpu_device_attr_create_groups() error handling Dan Carpenter
2020-05-20 12:05 ` Christian König
2020-05-20 12:52   ` Dan Carpenter
2020-05-20 13:08     ` [PATCH v2] " Dan Carpenter
2020-05-20 13:38       ` Wang, Kevin(Yang)
2020-05-20 15:23       ` Ruhl, Michael J
2020-05-20 15:25         ` [PATCH v3] drm/amdgpu: off by one " Dan Carpenter
2020-05-20 15:31           ` Ruhl, Michael J
2020-05-20 15:32             ` Christian König
2020-05-20 18:39               ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).