[PATCH v2] drm/amdgpu: off by on in amdgpu_device_attr_create_groups() error handling

Wang, Kevin(Yang) Kevin1.Wang at amd.com
Wed May 20 13:38:20 UTC 2020


[AMD Official Use Only - Internal Distribution Only]

thanks.

Reviewed-by: Kevin Wang <kevin1.wang at amd.com>

Best Regads,
Kevin
________________________________
From: Dan Carpenter <dan.carpenter at oracle.com>
Sent: Wednesday, May 20, 2020 9:08 PM
To: Deucher, Alexander <Alexander.Deucher at amd.com>; Wang, Kevin(Yang) <Kevin1.Wang at amd.com>
Cc: Koenig, Christian <Christian.Koenig at amd.com>; David Airlie <airlied at linux.ie>; Daniel Vetter <daniel at ffwll.ch>; Quan, Evan <Evan.Quan at amd.com>; Huang, Ray <Ray.Huang at amd.com>; Feng, Kenneth <Kenneth.Feng at amd.com>; Tao, Yintian <Yintian.Tao at amd.com>; Zhang, Hawking <Hawking.Zhang at amd.com>; amd-gfx at lists.freedesktop.org <amd-gfx at lists.freedesktop.org>; dri-devel at lists.freedesktop.org <dri-devel at lists.freedesktop.org>; linux-kernel at vger.kernel.org <linux-kernel at vger.kernel.org>; kernel-janitors at vger.kernel.org <kernel-janitors at vger.kernel.org>
Subject: [PATCH v2] 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 at oracle.com>
---
v2: style change

 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c           | 3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index b75362bf0742..e809534fabd4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -1942,9 +1942,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;
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20200520/da0e2d34/attachment-0001.htm>


More information about the dri-devel mailing list