* [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
* Re: [PATCH] drm/amdgpu: off by on in amdgpu_device_attr_create_groups() error handling
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
0 siblings, 1 reply; 10+ messages in thread
From: Christian König @ 2020-05-20 12:05 UTC (permalink / raw)
To: Dan Carpenter, Alex Deucher, Kevin Wang
Cc: David Airlie, kernel-janitors, linux-kernel, amd-gfx, Rui Huang,
dri-devel, Yintian Tao, Evan Quan, Kenneth Feng,
Christian König, Hawking Zhang
Am 20.05.20 um 14:00 schrieb Dan Carpenter:
> 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)
As far as I know the common idiom for this is while (i--) which even
works without changing the type of i to signed.
Christian.
> amdgpu_device_attr_remove(adev, &attrs[i]);
> - }
>
> return ret;
> }
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drm/amdgpu: off by on in amdgpu_device_attr_create_groups() error handling
2020-05-20 12:05 ` Christian König
@ 2020-05-20 12:52 ` Dan Carpenter
2020-05-20 13:08 ` [PATCH v2] " Dan Carpenter
0 siblings, 1 reply; 10+ messages in thread
From: Dan Carpenter @ 2020-05-20 12:52 UTC (permalink / raw)
To: christian.koenig
Cc: David Airlie, Kevin Wang, kernel-janitors, linux-kernel, amd-gfx,
Rui Huang, dri-devel, Alex Deucher, Yintian Tao, Evan Quan,
Kenneth Feng, Hawking Zhang
On Wed, May 20, 2020 at 02:05:19PM +0200, Christian König wrote:
> Am 20.05.20 um 14:00 schrieb Dan Carpenter:
> > 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)
>
> As far as I know the common idiom for this is while (i--) which even works
> without changing the type of i to signed.
It's about 50/50, one way or the other. To me --i >= 0 seems far more
readable.
I've been trying to figure out which tool tells people to make iterators
unsigned so I can help them avoid it. :/ I understand how in theory
iterators could go above INT_MAX but if we're going above INT_MAX then
probably we should use a 64 bit type. There are very few times where 2
billion iterations is not enough but in those situations probably 4
billion is not enough either. So unsigned int iterators never or seldom
solve real life bugs but they regularly cause them.
regards,
dan carpenter
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2] drm/amdgpu: off by on in amdgpu_device_attr_create_groups() error handling
2020-05-20 12:52 ` Dan Carpenter
@ 2020-05-20 13:08 ` Dan Carpenter
2020-05-20 13:38 ` Wang, Kevin(Yang)
2020-05-20 15:23 ` Ruhl, Michael J
0 siblings, 2 replies; 10+ messages in thread
From: Dan Carpenter @ 2020-05-20 13:08 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>
---
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;
}
_______________________________________________
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
* Re: [PATCH v2] drm/amdgpu: off by on in amdgpu_device_attr_create_groups() error handling
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
1 sibling, 0 replies; 10+ messages in thread
From: Wang, Kevin(Yang) @ 2020-05-20 13:38 UTC (permalink / raw)
To: Dan Carpenter, Deucher, Alexander
Cc: David Airlie, Tao, Yintian, kernel-janitors, linux-kernel,
amd-gfx, Huang, Ray, dri-devel, Quan, Evan, Feng, Kenneth,
Koenig, Christian, Zhang, Hawking
[-- Attachment #1.1: Type: text/plain, Size: 2015 bytes --]
[AMD Official Use Only - Internal Distribution Only]
thanks.
Reviewed-by: Kevin Wang <kevin1.wang@amd.com>
Best Regads,
Kevin
________________________________
From: Dan Carpenter <dan.carpenter@oracle.com>
Sent: Wednesday, May 20, 2020 9:08 PM
To: Deucher, Alexander <Alexander.Deucher@amd.com>; Wang, Kevin(Yang) <Kevin1.Wang@amd.com>
Cc: Koenig, Christian <Christian.Koenig@amd.com>; David Airlie <airlied@linux.ie>; Daniel Vetter <daniel@ffwll.ch>; Quan, Evan <Evan.Quan@amd.com>; Huang, Ray <Ray.Huang@amd.com>; Feng, Kenneth <Kenneth.Feng@amd.com>; Tao, Yintian <Yintian.Tao@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; dri-devel@lists.freedesktop.org <dri-devel@lists.freedesktop.org>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; kernel-janitors@vger.kernel.org <kernel-janitors@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@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;
}
[-- Attachment #1.2: Type: text/html, Size: 4018 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
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
* RE: [PATCH v2] drm/amdgpu: off by on in amdgpu_device_attr_create_groups() error handling
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
1 sibling, 1 reply; 10+ messages in thread
From: Ruhl, Michael J @ 2020-05-20 15:23 UTC (permalink / raw)
To: Dan Carpenter, Alex Deucher, Kevin Wang
Cc: David Airlie, kernel-janitors, linux-kernel, amd-gfx, Rui Huang,
dri-devel, Yintian Tao, Evan Quan, Kenneth Feng,
Christian König, Hawking Zhang
"off by on"
or
"off by one"
?
M
>-----Original Message-----
>From: dri-devel <dri-devel-bounces@lists.freedesktop.org> On Behalf Of Dan
>Carpenter
>Sent: Wednesday, May 20, 2020 9:08 AM
>To: Alex Deucher <alexander.deucher@amd.com>; Kevin Wang
><kevin1.wang@amd.com>
>Cc: David Airlie <airlied@linux.ie>; kernel-janitors@vger.kernel.org; linux-
>kernel@vger.kernel.org; amd-gfx@lists.freedesktop.org; Hawking Zhang
><Hawking.Zhang@amd.com>; Rui Huang <ray.huang@amd.com>; dri-
>devel@lists.freedesktop.org; Evan Quan <evan.quan@amd.com>; Kenneth
>Feng <kenneth.feng@amd.com>; Christian König
><christian.koenig@amd.com>; Yintian Tao <yttao@amd.com>
>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@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;
> }
>_______________________________________________
>dri-devel mailing list
>dri-devel@lists.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3] drm/amdgpu: off by one in amdgpu_device_attr_create_groups() error handling
2020-05-20 15:23 ` Ruhl, Michael J
@ 2020-05-20 15:25 ` Dan Carpenter
2020-05-20 15:31 ` Ruhl, Michael J
0 siblings, 1 reply; 10+ messages in thread
From: Dan Carpenter @ 2020-05-20 15:25 UTC (permalink / raw)
To: Alex Deucher, Kevin Wang, Ruhl, Michael J
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>
---
v2: style change
v3: Fix embarrassing typo in the subject
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;
}
_______________________________________________
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
* RE: [PATCH v3] drm/amdgpu: off by one in amdgpu_device_attr_create_groups() error handling
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
0 siblings, 1 reply; 10+ messages in thread
From: Ruhl, Michael J @ 2020-05-20 15:31 UTC (permalink / raw)
To: Dan Carpenter, 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
>-----Original Message-----
>From: Dan Carpenter <dan.carpenter@oracle.com>
>Sent: Wednesday, May 20, 2020 11:26 AM
>To: Alex Deucher <alexander.deucher@amd.com>; Kevin Wang
><kevin1.wang@amd.com>; Ruhl, Michael J <michael.j.ruhl@intel.com>
>Cc: Christian König <christian.koenig@amd.com>; David Airlie
><airlied@linux.ie>; Daniel Vetter <daniel@ffwll.ch>; Evan Quan
><evan.quan@amd.com>; Rui Huang <ray.huang@amd.com>; Kenneth Feng
><kenneth.feng@amd.com>; Yintian Tao <yttao@amd.com>; Hawking Zhang
><Hawking.Zhang@amd.com>; amd-gfx@lists.freedesktop.org; dri-
>devel@lists.freedesktop.org; linux-kernel@vger.kernel.org; kernel-
>janitors@vger.kernel.org
>Subject: [PATCH v3] 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: 4e01847c38f7 ("drm/amdgpu: optimize amdgpu device attribute code")
>Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>---
>v2: style change
>v3: Fix embarrassing typo in the subject
😊
Acked-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
m
> 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;
> }
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3] drm/amdgpu: off by one in amdgpu_device_attr_create_groups() error handling
2020-05-20 15:31 ` Ruhl, Michael J
@ 2020-05-20 15:32 ` Christian König
2020-05-20 18:39 ` Alex Deucher
0 siblings, 1 reply; 10+ messages in thread
From: Christian König @ 2020-05-20 15:32 UTC (permalink / raw)
To: Ruhl, Michael J, Dan Carpenter, Alex Deucher, Kevin Wang
Cc: David Airlie, kernel-janitors, linux-kernel, amd-gfx,
Hawking Zhang, Rui Huang, dri-devel, Evan Quan, Kenneth Feng,
Yintian Tao
Am 20.05.20 um 17:31 schrieb Ruhl, Michael J:
>> -----Original Message-----
>> From: Dan Carpenter <dan.carpenter@oracle.com>
>> Sent: Wednesday, May 20, 2020 11:26 AM
>> To: Alex Deucher <alexander.deucher@amd.com>; Kevin Wang
>> <kevin1.wang@amd.com>; Ruhl, Michael J <michael.j.ruhl@intel.com>
>> Cc: Christian König <christian.koenig@amd.com>; David Airlie
>> <airlied@linux.ie>; Daniel Vetter <daniel@ffwll.ch>; Evan Quan
>> <evan.quan@amd.com>; Rui Huang <ray.huang@amd.com>; Kenneth Feng
>> <kenneth.feng@amd.com>; Yintian Tao <yttao@amd.com>; Hawking Zhang
>> <Hawking.Zhang@amd.com>; amd-gfx@lists.freedesktop.org; dri-
>> devel@lists.freedesktop.org; linux-kernel@vger.kernel.org; kernel-
>> janitors@vger.kernel.org
>> Subject: [PATCH v3] 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: 4e01847c38f7 ("drm/amdgpu: optimize amdgpu device attribute code")
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>> ---
>> v2: style change
>> v3: Fix embarrassing typo in the subject
> 😊
>
> Acked-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
>
> m
>> 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;
>> }
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3] drm/amdgpu: off by one in amdgpu_device_attr_create_groups() error handling
2020-05-20 15:32 ` Christian König
@ 2020-05-20 18:39 ` Alex Deucher
0 siblings, 0 replies; 10+ messages in thread
From: Alex Deucher @ 2020-05-20 18:39 UTC (permalink / raw)
To: Christian König
Cc: David Airlie, Kevin Wang, kernel-janitors, linux-kernel, amd-gfx,
Ruhl, Michael J, Rui Huang, dri-devel, Alex Deucher, Yintian Tao,
Evan Quan, Kenneth Feng, Dan Carpenter, Hawking Zhang
[-- Attachment #1.1: Type: text/plain, Size: 2507 bytes --]
Applied. Thanks!
Alex
On Wed, May 20, 2020 at 11:33 AM Christian König <christian.koenig@amd.com>
wrote:
> Am 20.05.20 um 17:31 schrieb Ruhl, Michael J:
> >> -----Original Message-----
> >> From: Dan Carpenter <dan.carpenter@oracle.com>
> >> Sent: Wednesday, May 20, 2020 11:26 AM
> >> To: Alex Deucher <alexander.deucher@amd.com>; Kevin Wang
> >> <kevin1.wang@amd.com>; Ruhl, Michael J <michael.j.ruhl@intel.com>
> >> Cc: Christian König <christian.koenig@amd.com>; David Airlie
> >> <airlied@linux.ie>; Daniel Vetter <daniel@ffwll.ch>; Evan Quan
> >> <evan.quan@amd.com>; Rui Huang <ray.huang@amd.com>; Kenneth Feng
> >> <kenneth.feng@amd.com>; Yintian Tao <yttao@amd.com>; Hawking Zhang
> >> <Hawking.Zhang@amd.com>; amd-gfx@lists.freedesktop.org; dri-
> >> devel@lists.freedesktop.org; linux-kernel@vger.kernel.org; kernel-
> >> janitors@vger.kernel.org
> >> Subject: [PATCH v3] 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: 4e01847c38f7 ("drm/amdgpu: optimize amdgpu device attribute
> code")
> >> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >> ---
> >> v2: style change
> >> v3: Fix embarrassing typo in the subject
> > 😊
> >
> > Acked-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
>
> >
> > m
> >> 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;
> >> }
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
[-- Attachment #1.2: Type: text/html, Size: 4712 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [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).