* [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing
@ 2020-02-26 19:58 ` Colin King
0 siblings, 0 replies; 16+ messages in thread
From: Colin King @ 2020-02-26 19:58 UTC (permalink / raw)
To: Lee Jones, Daniel Thompson, Jingoo Han,
Bartlomiej Zolnierkiewicz, Gyungoh Yoo, Bryan Wu, dri-devel,
linux-fbdev
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
In the unlikely event that num_entry is zero, the while loop
pre-decrements num_entry to cause negative array indexing into the
array sources. Fix this by iterating only if num_entry >= 0.
Addresses-Coverity: ("Out-of-bounds read")
Fixes: f705806c9f35 ("backlight: Add support Skyworks SKY81452 backlight driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
V2: fix typo in commit subject line
---
drivers/video/backlight/sky81452-backlight.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
index 2355f00f5773..f456930ce78e 100644
--- a/drivers/video/backlight/sky81452-backlight.c
+++ b/drivers/video/backlight/sky81452-backlight.c
@@ -200,7 +200,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
}
pdata->enable = 0;
- while (--num_entry)
+ while (--num_entry >= 0)
pdata->enable |= (1 << sources[num_entry]);
}
--
2.25.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing
@ 2020-02-26 19:58 ` Colin King
0 siblings, 0 replies; 16+ messages in thread
From: Colin King @ 2020-02-26 19:58 UTC (permalink / raw)
To: Lee Jones, Daniel Thompson, Jingoo Han,
Bartlomiej Zolnierkiewicz, Gyungoh Yoo, Bryan Wu, dri-devel,
linux-fbdev
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
In the unlikely event that num_entry is zero, the while loop
pre-decrements num_entry to cause negative array indexing into the
array sources. Fix this by iterating only if num_entry >= 0.
Addresses-Coverity: ("Out-of-bounds read")
Fixes: f705806c9f35 ("backlight: Add support Skyworks SKY81452 backlight driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
V2: fix typo in commit subject line
---
drivers/video/backlight/sky81452-backlight.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
index 2355f00f5773..f456930ce78e 100644
--- a/drivers/video/backlight/sky81452-backlight.c
+++ b/drivers/video/backlight/sky81452-backlight.c
@@ -200,7 +200,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
}
pdata->enable = 0;
- while (--num_entry)
+ while (--num_entry >= 0)
pdata->enable |= (1 << sources[num_entry]);
}
--
2.25.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 16+ messages in thread
* AW: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing
2020-02-26 19:58 ` Colin King
@ 2020-02-27 11:15 ` Walter Harms
-1 siblings, 0 replies; 16+ messages in thread
From: Walter Harms @ 2020-02-27 11:15 UTC (permalink / raw)
To: Colin King, Lee Jones, Daniel Thompson, Jingoo Han,
Bartlomiej Zolnierkiewicz, Gyungoh Yoo, Bryan Wu, dri-devel,
linux-fbdev
Cc: kernel-janitors, linux-kernel
hi all,
i would suggest converting this in to a more common for() loop.
Programmers are bad in counting backwards. that kind of bug is
common.
re,
wh
________________________________________
Von: kernel-janitors-owner@vger.kernel.org <kernel-janitors-owner@vger.kernel.org> im Auftrag von Colin King <colin.king@canonical.com>
Gesendet: Mittwoch, 26. Februar 2020 20:58
An: Lee Jones; Daniel Thompson; Jingoo Han; Bartlomiej Zolnierkiewicz; Gyungoh Yoo; Bryan Wu; dri-devel@lists.freedesktop.org; linux-fbdev@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org
Betreff: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing
From: Colin Ian King <colin.king@canonical.com>
In the unlikely event that num_entry is zero, the while loop
pre-decrements num_entry to cause negative array indexing into the
array sources. Fix this by iterating only if num_entry >= 0.
Addresses-Coverity: ("Out-of-bounds read")
Fixes: f705806c9f35 ("backlight: Add support Skyworks SKY81452 backlight driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
V2: fix typo in commit subject line
---
drivers/video/backlight/sky81452-backlight.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
index 2355f00f5773..f456930ce78e 100644
--- a/drivers/video/backlight/sky81452-backlight.c
+++ b/drivers/video/backlight/sky81452-backlight.c
@@ -200,7 +200,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
}
pdata->enable = 0;
- while (--num_entry)
+ while (--num_entry >= 0)
pdata->enable |= (1 << sources[num_entry]);
int i;
for(i=0;i<num_entry;i++)
pdata->enable |= (1 << sources[i]);
}
--
2.25.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* AW: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing
@ 2020-02-27 11:15 ` Walter Harms
0 siblings, 0 replies; 16+ messages in thread
From: Walter Harms @ 2020-02-27 11:15 UTC (permalink / raw)
To: Colin King, Lee Jones, Daniel Thompson, Jingoo Han,
Bartlomiej Zolnierkiewicz, Gyungoh Yoo, Bryan Wu, dri-devel,
linux-fbdev
Cc: kernel-janitors, linux-kernel
hi all,
i would suggest converting this in to a more common for() loop.
Programmers are bad in counting backwards. that kind of bug is
common.
re,
wh
________________________________________
Von: kernel-janitors-owner@vger.kernel.org <kernel-janitors-owner@vger.kernel.org> im Auftrag von Colin King <colin.king@canonical.com>
Gesendet: Mittwoch, 26. Februar 2020 20:58
An: Lee Jones; Daniel Thompson; Jingoo Han; Bartlomiej Zolnierkiewicz; Gyungoh Yoo; Bryan Wu; dri-devel@lists.freedesktop.org; linux-fbdev@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org
Betreff: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing
From: Colin Ian King <colin.king@canonical.com>
In the unlikely event that num_entry is zero, the while loop
pre-decrements num_entry to cause negative array indexing into the
array sources. Fix this by iterating only if num_entry >= 0.
Addresses-Coverity: ("Out-of-bounds read")
Fixes: f705806c9f35 ("backlight: Add support Skyworks SKY81452 backlight driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
V2: fix typo in commit subject line
---
drivers/video/backlight/sky81452-backlight.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
index 2355f00f5773..f456930ce78e 100644
--- a/drivers/video/backlight/sky81452-backlight.c
+++ b/drivers/video/backlight/sky81452-backlight.c
@@ -200,7 +200,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
}
pdata->enable = 0;
- while (--num_entry)
+ while (--num_entry >= 0)
pdata->enable |= (1 << sources[num_entry]);
int i;
for(i=0;i<num_entry;i++)
pdata->enable |= (1 << sources[i]);
}
--
2.25.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing
2020-02-26 19:58 ` Colin King
(?)
@ 2020-02-27 11:46 ` Daniel Thompson
-1 siblings, 0 replies; 16+ messages in thread
From: Daniel Thompson @ 2020-02-27 11:46 UTC (permalink / raw)
To: Colin King
Cc: Lee Jones, Jingoo Han, Bartlomiej Zolnierkiewicz, Gyungoh Yoo,
Bryan Wu, dri-devel, linux-fbdev, kernel-janitors, linux-kernel
On Wed, Feb 26, 2020 at 07:58:26PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> In the unlikely event that num_entry is zero, the while loop
> pre-decrements num_entry to cause negative array indexing into the
> array sources. Fix this by iterating only if num_entry >= 0.
>
> Addresses-Coverity: ("Out-of-bounds read")
> Fixes: f705806c9f35 ("backlight: Add support Skyworks SKY81452 backlight driver")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>
> V2: fix typo in commit subject line
Isn't the correct spelling "ensure"?
> ---
> drivers/video/backlight/sky81452-backlight.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
> index 2355f00f5773..f456930ce78e 100644
> --- a/drivers/video/backlight/sky81452-backlight.c
> +++ b/drivers/video/backlight/sky81452-backlight.c
> @@ -200,7 +200,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
> }
>
> pdata->enable = 0;
> - while (--num_entry)
> + while (--num_entry >= 0)
> pdata->enable |= (1 << sources[num_entry]);
This look still looks buggy to me (so I'd second Walter's request to
change it to a for loop). If the code genuinely does not contain a
bug then it probably needs a prominent comment explaining why it is
correct not to honour sources[0]!
Daniel.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing
@ 2020-02-27 11:46 ` Daniel Thompson
0 siblings, 0 replies; 16+ messages in thread
From: Daniel Thompson @ 2020-02-27 11:46 UTC (permalink / raw)
To: Colin King
Cc: linux-fbdev, Bartlomiej Zolnierkiewicz, kernel-janitors,
Jingoo Han, Bryan Wu, Gyungoh Yoo, linux-kernel, dri-devel,
Lee Jones
On Wed, Feb 26, 2020 at 07:58:26PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> In the unlikely event that num_entry is zero, the while loop
> pre-decrements num_entry to cause negative array indexing into the
> array sources. Fix this by iterating only if num_entry >= 0.
>
> Addresses-Coverity: ("Out-of-bounds read")
> Fixes: f705806c9f35 ("backlight: Add support Skyworks SKY81452 backlight driver")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>
> V2: fix typo in commit subject line
Isn't the correct spelling "ensure"?
> ---
> drivers/video/backlight/sky81452-backlight.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
> index 2355f00f5773..f456930ce78e 100644
> --- a/drivers/video/backlight/sky81452-backlight.c
> +++ b/drivers/video/backlight/sky81452-backlight.c
> @@ -200,7 +200,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
> }
>
> pdata->enable = 0;
> - while (--num_entry)
> + while (--num_entry >= 0)
> pdata->enable |= (1 << sources[num_entry]);
This look still looks buggy to me (so I'd second Walter's request to
change it to a for loop). If the code genuinely does not contain a
bug then it probably needs a prominent comment explaining why it is
correct not to honour sources[0]!
Daniel.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing
@ 2020-02-27 11:46 ` Daniel Thompson
0 siblings, 0 replies; 16+ messages in thread
From: Daniel Thompson @ 2020-02-27 11:46 UTC (permalink / raw)
To: Colin King
Cc: linux-fbdev, Bartlomiej Zolnierkiewicz, kernel-janitors,
Jingoo Han, Bryan Wu, Gyungoh Yoo, linux-kernel, dri-devel,
Lee Jones
On Wed, Feb 26, 2020 at 07:58:26PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> In the unlikely event that num_entry is zero, the while loop
> pre-decrements num_entry to cause negative array indexing into the
> array sources. Fix this by iterating only if num_entry >= 0.
>
> Addresses-Coverity: ("Out-of-bounds read")
> Fixes: f705806c9f35 ("backlight: Add support Skyworks SKY81452 backlight driver")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>
> V2: fix typo in commit subject line
Isn't the correct spelling "ensure"?
> ---
> drivers/video/backlight/sky81452-backlight.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
> index 2355f00f5773..f456930ce78e 100644
> --- a/drivers/video/backlight/sky81452-backlight.c
> +++ b/drivers/video/backlight/sky81452-backlight.c
> @@ -200,7 +200,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
> }
>
> pdata->enable = 0;
> - while (--num_entry)
> + while (--num_entry >= 0)
> pdata->enable |= (1 << sources[num_entry]);
This look still looks buggy to me (so I'd second Walter's request to
change it to a for loop). If the code genuinely does not contain a
bug then it probably needs a prominent comment explaining why it is
correct not to honour sources[0]!
Daniel.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing
2020-02-27 11:46 ` Daniel Thompson
(?)
@ 2020-02-27 14:57 ` Daniel Thompson
-1 siblings, 0 replies; 16+ messages in thread
From: Daniel Thompson @ 2020-02-27 14:57 UTC (permalink / raw)
To: Colin King
Cc: Lee Jones, Jingoo Han, Bartlomiej Zolnierkiewicz, Gyungoh Yoo,
Bryan Wu, dri-devel, linux-fbdev, kernel-janitors, linux-kernel
On Thu, Feb 27, 2020 at 11:46:23AM +0000, Daniel Thompson wrote:
> On Wed, Feb 26, 2020 at 07:58:26PM +0000, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > In the unlikely event that num_entry is zero, the while loop
> > pre-decrements num_entry to cause negative array indexing into the
> > array sources. Fix this by iterating only if num_entry >= 0.
> >
> > Addresses-Coverity: ("Out-of-bounds read")
> > Fixes: f705806c9f35 ("backlight: Add support Skyworks SKY81452 backlight driver")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> >
> > V2: fix typo in commit subject line
>
> Isn't the correct spelling "ensure"?
>
>
> > ---
> > drivers/video/backlight/sky81452-backlight.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
> > index 2355f00f5773..f456930ce78e 100644
> > --- a/drivers/video/backlight/sky81452-backlight.c
> > +++ b/drivers/video/backlight/sky81452-backlight.c
> > @@ -200,7 +200,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
> > }
> >
> > pdata->enable = 0;
> > - while (--num_entry)
> > + while (--num_entry >= 0)
> > pdata->enable |= (1 << sources[num_entry]);
>
> This look still looks buggy to me (so I'd second Walter's request to
> change it to a for loop). If the code genuinely does not contain a
> bug then it probably needs a prominent comment explaining why it is
> correct not to honour sources[0]!
Ignore the "still looks buggy". A mental mis-step when switching
contexts...
I think my English is still correct though ;-)
Daniel.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing
@ 2020-02-27 14:57 ` Daniel Thompson
0 siblings, 0 replies; 16+ messages in thread
From: Daniel Thompson @ 2020-02-27 14:57 UTC (permalink / raw)
To: Colin King
Cc: linux-fbdev, Bartlomiej Zolnierkiewicz, kernel-janitors,
Jingoo Han, Bryan Wu, Gyungoh Yoo, linux-kernel, dri-devel,
Lee Jones
On Thu, Feb 27, 2020 at 11:46:23AM +0000, Daniel Thompson wrote:
> On Wed, Feb 26, 2020 at 07:58:26PM +0000, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > In the unlikely event that num_entry is zero, the while loop
> > pre-decrements num_entry to cause negative array indexing into the
> > array sources. Fix this by iterating only if num_entry >= 0.
> >
> > Addresses-Coverity: ("Out-of-bounds read")
> > Fixes: f705806c9f35 ("backlight: Add support Skyworks SKY81452 backlight driver")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> >
> > V2: fix typo in commit subject line
>
> Isn't the correct spelling "ensure"?
>
>
> > ---
> > drivers/video/backlight/sky81452-backlight.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
> > index 2355f00f5773..f456930ce78e 100644
> > --- a/drivers/video/backlight/sky81452-backlight.c
> > +++ b/drivers/video/backlight/sky81452-backlight.c
> > @@ -200,7 +200,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
> > }
> >
> > pdata->enable = 0;
> > - while (--num_entry)
> > + while (--num_entry >= 0)
> > pdata->enable |= (1 << sources[num_entry]);
>
> This look still looks buggy to me (so I'd second Walter's request to
> change it to a for loop). If the code genuinely does not contain a
> bug then it probably needs a prominent comment explaining why it is
> correct not to honour sources[0]!
Ignore the "still looks buggy". A mental mis-step when switching
contexts...
I think my English is still correct though ;-)
Daniel.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing
@ 2020-02-27 14:57 ` Daniel Thompson
0 siblings, 0 replies; 16+ messages in thread
From: Daniel Thompson @ 2020-02-27 14:57 UTC (permalink / raw)
To: Colin King
Cc: linux-fbdev, Bartlomiej Zolnierkiewicz, kernel-janitors,
Jingoo Han, Bryan Wu, Gyungoh Yoo, linux-kernel, dri-devel,
Lee Jones
On Thu, Feb 27, 2020 at 11:46:23AM +0000, Daniel Thompson wrote:
> On Wed, Feb 26, 2020 at 07:58:26PM +0000, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > In the unlikely event that num_entry is zero, the while loop
> > pre-decrements num_entry to cause negative array indexing into the
> > array sources. Fix this by iterating only if num_entry >= 0.
> >
> > Addresses-Coverity: ("Out-of-bounds read")
> > Fixes: f705806c9f35 ("backlight: Add support Skyworks SKY81452 backlight driver")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> >
> > V2: fix typo in commit subject line
>
> Isn't the correct spelling "ensure"?
>
>
> > ---
> > drivers/video/backlight/sky81452-backlight.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
> > index 2355f00f5773..f456930ce78e 100644
> > --- a/drivers/video/backlight/sky81452-backlight.c
> > +++ b/drivers/video/backlight/sky81452-backlight.c
> > @@ -200,7 +200,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
> > }
> >
> > pdata->enable = 0;
> > - while (--num_entry)
> > + while (--num_entry >= 0)
> > pdata->enable |= (1 << sources[num_entry]);
>
> This look still looks buggy to me (so I'd second Walter's request to
> change it to a for loop). If the code genuinely does not contain a
> bug then it probably needs a prominent comment explaining why it is
> correct not to honour sources[0]!
Ignore the "still looks buggy". A mental mis-step when switching
contexts...
I think my English is still correct though ;-)
Daniel.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing
2020-02-27 11:46 ` Daniel Thompson
(?)
@ 2020-02-27 15:10 ` Colin Ian King
-1 siblings, 0 replies; 16+ messages in thread
From: Colin Ian King @ 2020-02-27 15:10 UTC (permalink / raw)
To: Daniel Thompson
Cc: Lee Jones, Jingoo Han, Bartlomiej Zolnierkiewicz, Gyungoh Yoo,
Bryan Wu, dri-devel, linux-fbdev, kernel-janitors, linux-kernel
On 27/02/2020 11:46, Daniel Thompson wrote:
> On Wed, Feb 26, 2020 at 07:58:26PM +0000, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> In the unlikely event that num_entry is zero, the while loop
>> pre-decrements num_entry to cause negative array indexing into the
>> array sources. Fix this by iterating only if num_entry >= 0.
>>
>> Addresses-Coverity: ("Out-of-bounds read")
>> Fixes: f705806c9f35 ("backlight: Add support Skyworks SKY81452 backlight driver")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>
>> V2: fix typo in commit subject line
>
> Isn't the correct spelling "ensure"?
It is. V1 is correct after all. Doh.
>
>
>> ---
>> drivers/video/backlight/sky81452-backlight.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
>> index 2355f00f5773..f456930ce78e 100644
>> --- a/drivers/video/backlight/sky81452-backlight.c
>> +++ b/drivers/video/backlight/sky81452-backlight.c
>> @@ -200,7 +200,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
>> }
>>
>> pdata->enable = 0;
>> - while (--num_entry)
>> + while (--num_entry >= 0)
>> pdata->enable |= (1 << sources[num_entry]);
>
> This look still looks buggy to me (so I'd second Walter's request to
> change it to a for loop). If the code genuinely does not contain a
> bug then it probably needs a prominent comment explaining why it is
> correct not to honour sources[0]!
>
>
> Daniel.
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing
@ 2020-02-27 15:10 ` Colin Ian King
0 siblings, 0 replies; 16+ messages in thread
From: Colin Ian King @ 2020-02-27 15:10 UTC (permalink / raw)
To: Daniel Thompson
Cc: linux-fbdev, Bartlomiej Zolnierkiewicz, kernel-janitors,
Jingoo Han, Bryan Wu, Gyungoh Yoo, linux-kernel, dri-devel,
Lee Jones
On 27/02/2020 11:46, Daniel Thompson wrote:
> On Wed, Feb 26, 2020 at 07:58:26PM +0000, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> In the unlikely event that num_entry is zero, the while loop
>> pre-decrements num_entry to cause negative array indexing into the
>> array sources. Fix this by iterating only if num_entry >= 0.
>>
>> Addresses-Coverity: ("Out-of-bounds read")
>> Fixes: f705806c9f35 ("backlight: Add support Skyworks SKY81452 backlight driver")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>
>> V2: fix typo in commit subject line
>
> Isn't the correct spelling "ensure"?
It is. V1 is correct after all. Doh.
>
>
>> ---
>> drivers/video/backlight/sky81452-backlight.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
>> index 2355f00f5773..f456930ce78e 100644
>> --- a/drivers/video/backlight/sky81452-backlight.c
>> +++ b/drivers/video/backlight/sky81452-backlight.c
>> @@ -200,7 +200,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
>> }
>>
>> pdata->enable = 0;
>> - while (--num_entry)
>> + while (--num_entry >= 0)
>> pdata->enable |= (1 << sources[num_entry]);
>
> This look still looks buggy to me (so I'd second Walter's request to
> change it to a for loop). If the code genuinely does not contain a
> bug then it probably needs a prominent comment explaining why it is
> correct not to honour sources[0]!
>
>
> Daniel.
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing
@ 2020-02-27 15:10 ` Colin Ian King
0 siblings, 0 replies; 16+ messages in thread
From: Colin Ian King @ 2020-02-27 15:10 UTC (permalink / raw)
To: Daniel Thompson
Cc: linux-fbdev, Bartlomiej Zolnierkiewicz, kernel-janitors,
Jingoo Han, Bryan Wu, Gyungoh Yoo, linux-kernel, dri-devel,
Lee Jones
On 27/02/2020 11:46, Daniel Thompson wrote:
> On Wed, Feb 26, 2020 at 07:58:26PM +0000, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> In the unlikely event that num_entry is zero, the while loop
>> pre-decrements num_entry to cause negative array indexing into the
>> array sources. Fix this by iterating only if num_entry >= 0.
>>
>> Addresses-Coverity: ("Out-of-bounds read")
>> Fixes: f705806c9f35 ("backlight: Add support Skyworks SKY81452 backlight driver")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>
>> V2: fix typo in commit subject line
>
> Isn't the correct spelling "ensure"?
It is. V1 is correct after all. Doh.
>
>
>> ---
>> drivers/video/backlight/sky81452-backlight.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
>> index 2355f00f5773..f456930ce78e 100644
>> --- a/drivers/video/backlight/sky81452-backlight.c
>> +++ b/drivers/video/backlight/sky81452-backlight.c
>> @@ -200,7 +200,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
>> }
>>
>> pdata->enable = 0;
>> - while (--num_entry)
>> + while (--num_entry >= 0)
>> pdata->enable |= (1 << sources[num_entry]);
>
> This look still looks buggy to me (so I'd second Walter's request to
> change it to a for loop). If the code genuinely does not contain a
> bug then it probably needs a prominent comment explaining why it is
> correct not to honour sources[0]!
>
>
> Daniel.
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing
2020-02-27 15:10 ` Colin Ian King
(?)
@ 2020-02-28 16:45 ` Daniel Thompson
-1 siblings, 0 replies; 16+ messages in thread
From: Daniel Thompson @ 2020-02-28 16:45 UTC (permalink / raw)
To: Colin Ian King
Cc: Lee Jones, Jingoo Han, Bartlomiej Zolnierkiewicz, Gyungoh Yoo,
Bryan Wu, dri-devel, linux-fbdev, kernel-janitors, linux-kernel
On Thu, Feb 27, 2020 at 03:10:43PM +0000, Colin Ian King wrote:
> On 27/02/2020 11:46, Daniel Thompson wrote:
> > On Wed, Feb 26, 2020 at 07:58:26PM +0000, Colin King wrote:
> >> From: Colin Ian King <colin.king@canonical.com>
> >>
> >> In the unlikely event that num_entry is zero, the while loop
> >> pre-decrements num_entry to cause negative array indexing into the
> >> array sources. Fix this by iterating only if num_entry >= 0.
> >>
> >> Addresses-Coverity: ("Out-of-bounds read")
> >> Fixes: f705806c9f35 ("backlight: Add support Skyworks SKY81452 backlight driver")
> >> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> >> ---
> >>
> >> V2: fix typo in commit subject line
> >
> > Isn't the correct spelling "ensure"?
>
> It is. V1 is correct after all. Doh.
It wasn't spelt "ensure" in v1...
Daniel.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing
@ 2020-02-28 16:45 ` Daniel Thompson
0 siblings, 0 replies; 16+ messages in thread
From: Daniel Thompson @ 2020-02-28 16:45 UTC (permalink / raw)
To: Colin Ian King
Cc: linux-fbdev, Bartlomiej Zolnierkiewicz, kernel-janitors,
Jingoo Han, Bryan Wu, Gyungoh Yoo, linux-kernel, dri-devel,
Lee Jones
On Thu, Feb 27, 2020 at 03:10:43PM +0000, Colin Ian King wrote:
> On 27/02/2020 11:46, Daniel Thompson wrote:
> > On Wed, Feb 26, 2020 at 07:58:26PM +0000, Colin King wrote:
> >> From: Colin Ian King <colin.king@canonical.com>
> >>
> >> In the unlikely event that num_entry is zero, the while loop
> >> pre-decrements num_entry to cause negative array indexing into the
> >> array sources. Fix this by iterating only if num_entry >= 0.
> >>
> >> Addresses-Coverity: ("Out-of-bounds read")
> >> Fixes: f705806c9f35 ("backlight: Add support Skyworks SKY81452 backlight driver")
> >> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> >> ---
> >>
> >> V2: fix typo in commit subject line
> >
> > Isn't the correct spelling "ensure"?
>
> It is. V1 is correct after all. Doh.
It wasn't spelt "ensure" in v1...
Daniel.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing
@ 2020-02-28 16:45 ` Daniel Thompson
0 siblings, 0 replies; 16+ messages in thread
From: Daniel Thompson @ 2020-02-28 16:45 UTC (permalink / raw)
To: Colin Ian King
Cc: linux-fbdev, Bartlomiej Zolnierkiewicz, kernel-janitors,
Jingoo Han, Bryan Wu, Gyungoh Yoo, linux-kernel, dri-devel,
Lee Jones
On Thu, Feb 27, 2020 at 03:10:43PM +0000, Colin Ian King wrote:
> On 27/02/2020 11:46, Daniel Thompson wrote:
> > On Wed, Feb 26, 2020 at 07:58:26PM +0000, Colin King wrote:
> >> From: Colin Ian King <colin.king@canonical.com>
> >>
> >> In the unlikely event that num_entry is zero, the while loop
> >> pre-decrements num_entry to cause negative array indexing into the
> >> array sources. Fix this by iterating only if num_entry >= 0.
> >>
> >> Addresses-Coverity: ("Out-of-bounds read")
> >> Fixes: f705806c9f35 ("backlight: Add support Skyworks SKY81452 backlight driver")
> >> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> >> ---
> >>
> >> V2: fix typo in commit subject line
> >
> > Isn't the correct spelling "ensure"?
>
> It is. V1 is correct after all. Doh.
It wasn't spelt "ensure" in v1...
Daniel.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2020-02-28 16:46 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-26 19:58 [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing Colin King
2020-02-26 19:58 ` Colin King
2020-02-27 11:15 ` AW: " Walter Harms
2020-02-27 11:15 ` Walter Harms
2020-02-27 11:46 ` Daniel Thompson
2020-02-27 11:46 ` Daniel Thompson
2020-02-27 11:46 ` Daniel Thompson
2020-02-27 14:57 ` Daniel Thompson
2020-02-27 14:57 ` Daniel Thompson
2020-02-27 14:57 ` Daniel Thompson
2020-02-27 15:10 ` Colin Ian King
2020-02-27 15:10 ` Colin Ian King
2020-02-27 15:10 ` Colin Ian King
2020-02-28 16:45 ` Daniel Thompson
2020-02-28 16:45 ` Daniel Thompson
2020-02-28 16:45 ` Daniel Thompson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.