diff mbox

omapfb: invalid test on unsigned

Message ID 4A3FEB2F.8040307@gmail.com (mailing list archive)
State Not Applicable, archived
Delegated to: Tomi Valkeinen
Headers show

Commit Message

Roel Kluin June 22, 2009, 8:35 p.m. UTC
Unsigned regno cannot be less than 0.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Is this correct? please review.

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Krzysztof Helt June 22, 2009, 7:35 p.m. UTC | #1
On Mon, 22 Jun 2009 22:35:59 +0200
Roel Kluin <roel.kluin@gmail.com> wrote:

> Unsigned regno cannot be less than 0.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> Is this correct? please review.
> 

No. It is a case for truecolor modes. They do not use the cmap. 
Either remove the if clause completely or make it a an else clause for the next if

if (regno < 16) {
...
} else {
    r = -EINVAL;
}


The latter (the else clause) is a better solution.

Kind regards,
Krzysztof

> diff --git a/drivers/video/omap/omapfb_main.c b/drivers/video/omap/omapfb_main.c
> index 060d72f..787271f 100644
> --- a/drivers/video/omap/omapfb_main.c
> +++ b/drivers/video/omap/omapfb_main.c
> @@ -276,7 +276,7 @@ static int _setcolreg(struct fb_info *info, u_int regno, u_int red, u_int green,
>  		if (r != 0)
>  			break;
>  
> -		if (regno < 0) {
> +		if (regno >= info->cmap.len) {
>  			r = -EINVAL;
>  			break;
>  		}
> 
> ------------------------------------------------------------------------------
> Are you an open source citizen? Join us for the Open Source Bridge conference!
> Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
> Need another reason to go? 24-hour hacker lounge. Register today!
> http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
> _______________________________________________
> Linux-fbdev-devel mailing list
> Linux-fbdev-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel
> 

----------------------------------------------------------------------
Nowa akcja Pepsi - nagrody za kody spod nakretek. Zarejestruj sie!
http://link.interia.pl/f21cc 


--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/video/omap/omapfb_main.c b/drivers/video/omap/omapfb_main.c
index 060d72f..787271f 100644
--- a/drivers/video/omap/omapfb_main.c
+++ b/drivers/video/omap/omapfb_main.c
@@ -276,7 +276,7 @@  static int _setcolreg(struct fb_info *info, u_int regno, u_int red, u_int green,
 		if (r != 0)
 			break;
 
-		if (regno < 0) {
+		if (regno >= info->cmap.len) {
 			r = -EINVAL;
 			break;
 		}