public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [2.6 patch] video/sis/: fix negative array index
@ 2007-10-27 14:19 Adrian Bunk
  2007-11-01 22:17 ` Andrew Morton
  2007-11-01 22:21 ` Andrew Morton
  0 siblings, 2 replies; 3+ messages in thread
From: Adrian Bunk @ 2007-10-27 14:19 UTC (permalink / raw)
  To: adaplas; +Cc: linux-kernel

This patch fixes the possible usage of a negative value as an array 
index spotted by the Coverity checker.

Signed-off-by: Adrian Bunk <bunk@kernel.org>

---

 drivers/video/sis/sis_main.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

9f63bf8c543710521e885b09d88271d1a308b158 
diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c
index bc7d236..37bd24b 100644
--- a/drivers/video/sis/sis_main.c
+++ b/drivers/video/sis/sis_main.c
@@ -1245,24 +1245,25 @@ sisfb_do_set_var(struct fb_var_screeninfo *var, int isactive, struct fb_info *in
 		ivideo->sisfb_mode_idx++;
 	}
 
 	if(found_mode) {
 		ivideo->sisfb_mode_idx = sisfb_validate_mode(ivideo,
 				ivideo->sisfb_mode_idx, ivideo->currentvbflags);
-		ivideo->mode_no = sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni];
 	} else {
 		ivideo->sisfb_mode_idx = -1;
 	}
 
        	if(ivideo->sisfb_mode_idx < 0) {
 		printk(KERN_ERR "sisfb: Mode %dx%dx%d not supported\n", var->xres,
 		       var->yres, var->bits_per_pixel);
 		ivideo->sisfb_mode_idx = old_mode;
 		return -EINVAL;
 	}
 
+	ivideo->mode_no = sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni];
+
 	if(sisfb_search_refresh_rate(ivideo, ivideo->refresh_rate, ivideo->sisfb_mode_idx) == 0) {
 		ivideo->rate_idx = sisbios_mode[ivideo->sisfb_mode_idx].rate_idx;
 		ivideo->refresh_rate = 60;
 	}
 
 	if(isactive) {


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

* Re: [2.6 patch] video/sis/: fix negative array index
  2007-10-27 14:19 [2.6 patch] video/sis/: fix negative array index Adrian Bunk
@ 2007-11-01 22:17 ` Andrew Morton
  2007-11-01 22:21 ` Andrew Morton
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2007-11-01 22:17 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: adaplas, linux-kernel, Thomas Winischhofer

On Sat, 27 Oct 2007 16:19:46 +0200
Adrian Bunk <bunk@kernel.org> wrote:

> This patch fixes the possible usage of a negative value as an array 
> index spotted by the Coverity checker.
> 
> Signed-off-by: Adrian Bunk <bunk@kernel.org>
> 
> ---
> 
>  drivers/video/sis/sis_main.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> 9f63bf8c543710521e885b09d88271d1a308b158 
> diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c
> index bc7d236..37bd24b 100644
> --- a/drivers/video/sis/sis_main.c
> +++ b/drivers/video/sis/sis_main.c
> @@ -1245,24 +1245,25 @@ sisfb_do_set_var(struct fb_var_screeninfo *var, int isactive, struct fb_info *in
>  		ivideo->sisfb_mode_idx++;
>  	}
>  
>  	if(found_mode) {
>  		ivideo->sisfb_mode_idx = sisfb_validate_mode(ivideo,
>  				ivideo->sisfb_mode_idx, ivideo->currentvbflags);
> -		ivideo->mode_no = sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni];
>  	} else {
>  		ivideo->sisfb_mode_idx = -1;
>  	}
>  
>         	if(ivideo->sisfb_mode_idx < 0) {
>  		printk(KERN_ERR "sisfb: Mode %dx%dx%d not supported\n", var->xres,
>  		       var->yres, var->bits_per_pixel);
>  		ivideo->sisfb_mode_idx = old_mode;
>  		return -EINVAL;
>  	}
>  
> +	ivideo->mode_no = sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni];
> +
>  	if(sisfb_search_refresh_rate(ivideo, ivideo->refresh_rate, ivideo->sisfb_mode_idx) == 0) {
>  		ivideo->rate_idx = sisbios_mode[ivideo->sisfb_mode_idx].rate_idx;
>  		ivideo->refresh_rate = 60;
>  	}

Well I spent a little time trying to work out what the actual bug is and
gave up.  There doesn't appear to be any error in sisfb_do_set_var().

Better changelogs, please.

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

* Re: [2.6 patch] video/sis/: fix negative array index
  2007-10-27 14:19 [2.6 patch] video/sis/: fix negative array index Adrian Bunk
  2007-11-01 22:17 ` Andrew Morton
@ 2007-11-01 22:21 ` Andrew Morton
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2007-11-01 22:21 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: adaplas, linux-kernel, Thomas Winischhofer

On Sat, 27 Oct 2007 16:19:46 +0200
Adrian Bunk <bunk@kernel.org> wrote:

> --- a/drivers/video/sis/sis_main.c
> +++ b/drivers/video/sis/sis_main.c
> @@ -1245,24 +1245,25 @@ sisfb_do_set_var(struct fb_var_screeninfo *var, int isactive, struct fb_info *in
>  		ivideo->sisfb_mode_idx++;
>  	}
>  
>  	if(found_mode) {
>  		ivideo->sisfb_mode_idx = sisfb_validate_mode(ivideo,
>  				ivideo->sisfb_mode_idx, ivideo->currentvbflags);
> -		ivideo->mode_no = sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni];
>  	} else {
>  		ivideo->sisfb_mode_idx = -1;
>  	}
>  
>         	if(ivideo->sisfb_mode_idx < 0) {
>  		printk(KERN_ERR "sisfb: Mode %dx%dx%d not supported\n", var->xres,
>  		       var->yres, var->bits_per_pixel);
>  		ivideo->sisfb_mode_idx = old_mode;
>  		return -EINVAL;
>  	}
>  
> +	ivideo->mode_no = sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni];

oic, sisfb_validate_mode() could have returned a -ve error code.

Please use the changelog to fully explain your patches.

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

end of thread, other threads:[~2007-11-01 22:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-27 14:19 [2.6 patch] video/sis/: fix negative array index Adrian Bunk
2007-11-01 22:17 ` Andrew Morton
2007-11-01 22:21 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox