All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] video: fbdev: fix setting of pixclock because a pass-by-value error
@ 2020-07-23 17:02   ` Colin King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2020-07-23 17:02 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz, Daniel Vetter, Jani Nikula, dri-devel,
	linux-fbdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The pixclock is being set locally because it is being passed as a
pass-by-value argument rather than pass-by-reference, so the computed
pixclock is never being set in var->pixclock. Fix this by passing
by reference.

[This dates back to 2002, I found the offending commit from the git
history git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git ]

Addresses-Coverity: ("Unused value")
Fixes: 115f4504a64a ("Removed currcon and other console related code. Very little is now left.")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/video/fbdev/vga16fb.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/vga16fb.c b/drivers/video/fbdev/vga16fb.c
index a20eeb8308ff..52f273af6cae 100644
--- a/drivers/video/fbdev/vga16fb.c
+++ b/drivers/video/fbdev/vga16fb.c
@@ -243,7 +243,7 @@ static void vga16fb_update_fix(struct fb_info *info)
 }
 
 static void vga16fb_clock_chip(struct vga16fb_par *par,
-			       unsigned int pixclock,
+			       unsigned int *pixclock,
 			       const struct fb_info *info,
 			       int mul, int div)
 {
@@ -259,14 +259,14 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
 		{     0 /* bad */,    0x00, 0x00}};
 	int err;
 
-	pixclock = (pixclock * mul) / div;
+	*pixclock = (*pixclock * mul) / div;
 	best = vgaclocks;
-	err = pixclock - best->pixclock;
+	err = *pixclock - best->pixclock;
 	if (err < 0) err = -err;
 	for (ptr = vgaclocks + 1; ptr->pixclock; ptr++) {
 		int tmp;
 
-		tmp = pixclock - ptr->pixclock;
+		tmp = *pixclock - ptr->pixclock;
 		if (tmp < 0) tmp = -tmp;
 		if (tmp < err) {
 			err = tmp;
@@ -275,7 +275,7 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
 	}
 	par->misc |= best->misc;
 	par->clkdiv = best->seq_clock_mode;
-	pixclock = (best->pixclock * div) / mul;		
+	*pixclock = (best->pixclock * div) / mul;
 }
 			       
 #define FAIL(X) return -EINVAL
@@ -497,10 +497,10 @@ static int vga16fb_check_var(struct fb_var_screeninfo *var,
 
 	if (mode & MODE_8BPP)
 		/* pixel clock == vga clock / 2 */
-		vga16fb_clock_chip(par, var->pixclock, info, 1, 2);
+		vga16fb_clock_chip(par, &var->pixclock, info, 1, 2);
 	else
 		/* pixel clock == vga clock */
-		vga16fb_clock_chip(par, var->pixclock, info, 1, 1);
+		vga16fb_clock_chip(par, &var->pixclock, info, 1, 1);
 	
 	var->red.offset = var->green.offset = var->blue.offset = 
 	var->transp.offset = 0;
-- 
2.27.0


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

* [PATCH] video: fbdev: fix setting of pixclock because a pass-by-value error
@ 2020-07-23 17:02   ` Colin King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2020-07-23 17:02 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz, Daniel Vetter, Jani Nikula, dri-devel,
	linux-fbdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The pixclock is being set locally because it is being passed as a
pass-by-value argument rather than pass-by-reference, so the computed
pixclock is never being set in var->pixclock. Fix this by passing
by reference.

[This dates back to 2002, I found the offending commit from the git
history git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git ]

Addresses-Coverity: ("Unused value")
Fixes: 115f4504a64a ("Removed currcon and other console related code. Very little is now left.")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/video/fbdev/vga16fb.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/vga16fb.c b/drivers/video/fbdev/vga16fb.c
index a20eeb8308ff..52f273af6cae 100644
--- a/drivers/video/fbdev/vga16fb.c
+++ b/drivers/video/fbdev/vga16fb.c
@@ -243,7 +243,7 @@ static void vga16fb_update_fix(struct fb_info *info)
 }
 
 static void vga16fb_clock_chip(struct vga16fb_par *par,
-			       unsigned int pixclock,
+			       unsigned int *pixclock,
 			       const struct fb_info *info,
 			       int mul, int div)
 {
@@ -259,14 +259,14 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
 		{     0 /* bad */,    0x00, 0x00}};
 	int err;
 
-	pixclock = (pixclock * mul) / div;
+	*pixclock = (*pixclock * mul) / div;
 	best = vgaclocks;
-	err = pixclock - best->pixclock;
+	err = *pixclock - best->pixclock;
 	if (err < 0) err = -err;
 	for (ptr = vgaclocks + 1; ptr->pixclock; ptr++) {
 		int tmp;
 
-		tmp = pixclock - ptr->pixclock;
+		tmp = *pixclock - ptr->pixclock;
 		if (tmp < 0) tmp = -tmp;
 		if (tmp < err) {
 			err = tmp;
@@ -275,7 +275,7 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
 	}
 	par->misc |= best->misc;
 	par->clkdiv = best->seq_clock_mode;
-	pixclock = (best->pixclock * div) / mul;		
+	*pixclock = (best->pixclock * div) / mul;
 }
 			       
 #define FAIL(X) return -EINVAL
@@ -497,10 +497,10 @@ static int vga16fb_check_var(struct fb_var_screeninfo *var,
 
 	if (mode & MODE_8BPP)
 		/* pixel clock = vga clock / 2 */
-		vga16fb_clock_chip(par, var->pixclock, info, 1, 2);
+		vga16fb_clock_chip(par, &var->pixclock, info, 1, 2);
 	else
 		/* pixel clock = vga clock */
-		vga16fb_clock_chip(par, var->pixclock, info, 1, 1);
+		vga16fb_clock_chip(par, &var->pixclock, info, 1, 1);
 	
 	var->red.offset = var->green.offset = var->blue.offset = 
 	var->transp.offset = 0;
-- 
2.27.0

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

* [PATCH] video: fbdev: fix setting of pixclock because a pass-by-value error
@ 2020-07-23 17:02   ` Colin King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2020-07-23 17:02 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz, Daniel Vetter, Jani Nikula, dri-devel,
	linux-fbdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The pixclock is being set locally because it is being passed as a
pass-by-value argument rather than pass-by-reference, so the computed
pixclock is never being set in var->pixclock. Fix this by passing
by reference.

[This dates back to 2002, I found the offending commit from the git
history git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git ]

Addresses-Coverity: ("Unused value")
Fixes: 115f4504a64a ("Removed currcon and other console related code. Very little is now left.")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/video/fbdev/vga16fb.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/vga16fb.c b/drivers/video/fbdev/vga16fb.c
index a20eeb8308ff..52f273af6cae 100644
--- a/drivers/video/fbdev/vga16fb.c
+++ b/drivers/video/fbdev/vga16fb.c
@@ -243,7 +243,7 @@ static void vga16fb_update_fix(struct fb_info *info)
 }
 
 static void vga16fb_clock_chip(struct vga16fb_par *par,
-			       unsigned int pixclock,
+			       unsigned int *pixclock,
 			       const struct fb_info *info,
 			       int mul, int div)
 {
@@ -259,14 +259,14 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
 		{     0 /* bad */,    0x00, 0x00}};
 	int err;
 
-	pixclock = (pixclock * mul) / div;
+	*pixclock = (*pixclock * mul) / div;
 	best = vgaclocks;
-	err = pixclock - best->pixclock;
+	err = *pixclock - best->pixclock;
 	if (err < 0) err = -err;
 	for (ptr = vgaclocks + 1; ptr->pixclock; ptr++) {
 		int tmp;
 
-		tmp = pixclock - ptr->pixclock;
+		tmp = *pixclock - ptr->pixclock;
 		if (tmp < 0) tmp = -tmp;
 		if (tmp < err) {
 			err = tmp;
@@ -275,7 +275,7 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
 	}
 	par->misc |= best->misc;
 	par->clkdiv = best->seq_clock_mode;
-	pixclock = (best->pixclock * div) / mul;		
+	*pixclock = (best->pixclock * div) / mul;
 }
 			       
 #define FAIL(X) return -EINVAL
@@ -497,10 +497,10 @@ static int vga16fb_check_var(struct fb_var_screeninfo *var,
 
 	if (mode & MODE_8BPP)
 		/* pixel clock == vga clock / 2 */
-		vga16fb_clock_chip(par, var->pixclock, info, 1, 2);
+		vga16fb_clock_chip(par, &var->pixclock, info, 1, 2);
 	else
 		/* pixel clock == vga clock */
-		vga16fb_clock_chip(par, var->pixclock, info, 1, 1);
+		vga16fb_clock_chip(par, &var->pixclock, info, 1, 1);
 	
 	var->red.offset = var->green.offset = var->blue.offset = 
 	var->transp.offset = 0;
-- 
2.27.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] video: fbdev: fix setting of pixclock because a pass-by-value error
  2020-07-23 17:02   ` Colin King
  (?)
@ 2020-09-08 11:36     ` Bartlomiej Zolnierkiewicz
  -1 siblings, 0 replies; 6+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2020-09-08 11:36 UTC (permalink / raw)
  To: Colin King
  Cc: Daniel Vetter, Jani Nikula, dri-devel, linux-fbdev,
	kernel-janitors, linux-kernel


On 7/23/20 7:02 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The pixclock is being set locally because it is being passed as a
> pass-by-value argument rather than pass-by-reference, so the computed
> pixclock is never being set in var->pixclock. Fix this by passing
> by reference.
> 
> [This dates back to 2002, I found the offending commit from the git
> history git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git ]
> 
> Addresses-Coverity: ("Unused value")
> Fixes: 115f4504a64a ("Removed currcon and other console related code. Very little is now left.")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied to drm-misc-next tree, thanks and sorry for the delay.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

> ---
>  drivers/video/fbdev/vga16fb.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/video/fbdev/vga16fb.c b/drivers/video/fbdev/vga16fb.c
> index a20eeb8308ff..52f273af6cae 100644
> --- a/drivers/video/fbdev/vga16fb.c
> +++ b/drivers/video/fbdev/vga16fb.c
> @@ -243,7 +243,7 @@ static void vga16fb_update_fix(struct fb_info *info)
>  }
>  
>  static void vga16fb_clock_chip(struct vga16fb_par *par,
> -			       unsigned int pixclock,
> +			       unsigned int *pixclock,
>  			       const struct fb_info *info,
>  			       int mul, int div)
>  {
> @@ -259,14 +259,14 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
>  		{     0 /* bad */,    0x00, 0x00}};
>  	int err;
>  
> -	pixclock = (pixclock * mul) / div;
> +	*pixclock = (*pixclock * mul) / div;
>  	best = vgaclocks;
> -	err = pixclock - best->pixclock;
> +	err = *pixclock - best->pixclock;
>  	if (err < 0) err = -err;
>  	for (ptr = vgaclocks + 1; ptr->pixclock; ptr++) {
>  		int tmp;
>  
> -		tmp = pixclock - ptr->pixclock;
> +		tmp = *pixclock - ptr->pixclock;
>  		if (tmp < 0) tmp = -tmp;
>  		if (tmp < err) {
>  			err = tmp;
> @@ -275,7 +275,7 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
>  	}
>  	par->misc |= best->misc;
>  	par->clkdiv = best->seq_clock_mode;
> -	pixclock = (best->pixclock * div) / mul;		
> +	*pixclock = (best->pixclock * div) / mul;
>  }
>  			       
>  #define FAIL(X) return -EINVAL
> @@ -497,10 +497,10 @@ static int vga16fb_check_var(struct fb_var_screeninfo *var,
>  
>  	if (mode & MODE_8BPP)
>  		/* pixel clock == vga clock / 2 */
> -		vga16fb_clock_chip(par, var->pixclock, info, 1, 2);
> +		vga16fb_clock_chip(par, &var->pixclock, info, 1, 2);
>  	else
>  		/* pixel clock == vga clock */
> -		vga16fb_clock_chip(par, var->pixclock, info, 1, 1);
> +		vga16fb_clock_chip(par, &var->pixclock, info, 1, 1);
>  	
>  	var->red.offset = var->green.offset = var->blue.offset = 
>  	var->transp.offset = 0;
> 

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

* Re: [PATCH] video: fbdev: fix setting of pixclock because a pass-by-value error
@ 2020-09-08 11:36     ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 6+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2020-09-08 11:36 UTC (permalink / raw)
  To: Colin King
  Cc: linux-fbdev, Jani Nikula, Daniel Vetter, kernel-janitors,
	linux-kernel, dri-devel


On 7/23/20 7:02 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The pixclock is being set locally because it is being passed as a
> pass-by-value argument rather than pass-by-reference, so the computed
> pixclock is never being set in var->pixclock. Fix this by passing
> by reference.
> 
> [This dates back to 2002, I found the offending commit from the git
> history git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git ]
> 
> Addresses-Coverity: ("Unused value")
> Fixes: 115f4504a64a ("Removed currcon and other console related code. Very little is now left.")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied to drm-misc-next tree, thanks and sorry for the delay.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

> ---
>  drivers/video/fbdev/vga16fb.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/video/fbdev/vga16fb.c b/drivers/video/fbdev/vga16fb.c
> index a20eeb8308ff..52f273af6cae 100644
> --- a/drivers/video/fbdev/vga16fb.c
> +++ b/drivers/video/fbdev/vga16fb.c
> @@ -243,7 +243,7 @@ static void vga16fb_update_fix(struct fb_info *info)
>  }
>  
>  static void vga16fb_clock_chip(struct vga16fb_par *par,
> -			       unsigned int pixclock,
> +			       unsigned int *pixclock,
>  			       const struct fb_info *info,
>  			       int mul, int div)
>  {
> @@ -259,14 +259,14 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
>  		{     0 /* bad */,    0x00, 0x00}};
>  	int err;
>  
> -	pixclock = (pixclock * mul) / div;
> +	*pixclock = (*pixclock * mul) / div;
>  	best = vgaclocks;
> -	err = pixclock - best->pixclock;
> +	err = *pixclock - best->pixclock;
>  	if (err < 0) err = -err;
>  	for (ptr = vgaclocks + 1; ptr->pixclock; ptr++) {
>  		int tmp;
>  
> -		tmp = pixclock - ptr->pixclock;
> +		tmp = *pixclock - ptr->pixclock;
>  		if (tmp < 0) tmp = -tmp;
>  		if (tmp < err) {
>  			err = tmp;
> @@ -275,7 +275,7 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
>  	}
>  	par->misc |= best->misc;
>  	par->clkdiv = best->seq_clock_mode;
> -	pixclock = (best->pixclock * div) / mul;		
> +	*pixclock = (best->pixclock * div) / mul;
>  }
>  			       
>  #define FAIL(X) return -EINVAL
> @@ -497,10 +497,10 @@ static int vga16fb_check_var(struct fb_var_screeninfo *var,
>  
>  	if (mode & MODE_8BPP)
>  		/* pixel clock = vga clock / 2 */
> -		vga16fb_clock_chip(par, var->pixclock, info, 1, 2);
> +		vga16fb_clock_chip(par, &var->pixclock, info, 1, 2);
>  	else
>  		/* pixel clock = vga clock */
> -		vga16fb_clock_chip(par, var->pixclock, info, 1, 1);
> +		vga16fb_clock_chip(par, &var->pixclock, info, 1, 1);
>  	
>  	var->red.offset = var->green.offset = var->blue.offset = 
>  	var->transp.offset = 0;
> 

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

* Re: [PATCH] video: fbdev: fix setting of pixclock because a pass-by-value error
@ 2020-09-08 11:36     ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 6+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2020-09-08 11:36 UTC (permalink / raw)
  To: Colin King
  Cc: linux-fbdev, Jani Nikula, Daniel Vetter, kernel-janitors,
	linux-kernel, dri-devel


On 7/23/20 7:02 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The pixclock is being set locally because it is being passed as a
> pass-by-value argument rather than pass-by-reference, so the computed
> pixclock is never being set in var->pixclock. Fix this by passing
> by reference.
> 
> [This dates back to 2002, I found the offending commit from the git
> history git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git ]
> 
> Addresses-Coverity: ("Unused value")
> Fixes: 115f4504a64a ("Removed currcon and other console related code. Very little is now left.")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied to drm-misc-next tree, thanks and sorry for the delay.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

> ---
>  drivers/video/fbdev/vga16fb.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/video/fbdev/vga16fb.c b/drivers/video/fbdev/vga16fb.c
> index a20eeb8308ff..52f273af6cae 100644
> --- a/drivers/video/fbdev/vga16fb.c
> +++ b/drivers/video/fbdev/vga16fb.c
> @@ -243,7 +243,7 @@ static void vga16fb_update_fix(struct fb_info *info)
>  }
>  
>  static void vga16fb_clock_chip(struct vga16fb_par *par,
> -			       unsigned int pixclock,
> +			       unsigned int *pixclock,
>  			       const struct fb_info *info,
>  			       int mul, int div)
>  {
> @@ -259,14 +259,14 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
>  		{     0 /* bad */,    0x00, 0x00}};
>  	int err;
>  
> -	pixclock = (pixclock * mul) / div;
> +	*pixclock = (*pixclock * mul) / div;
>  	best = vgaclocks;
> -	err = pixclock - best->pixclock;
> +	err = *pixclock - best->pixclock;
>  	if (err < 0) err = -err;
>  	for (ptr = vgaclocks + 1; ptr->pixclock; ptr++) {
>  		int tmp;
>  
> -		tmp = pixclock - ptr->pixclock;
> +		tmp = *pixclock - ptr->pixclock;
>  		if (tmp < 0) tmp = -tmp;
>  		if (tmp < err) {
>  			err = tmp;
> @@ -275,7 +275,7 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
>  	}
>  	par->misc |= best->misc;
>  	par->clkdiv = best->seq_clock_mode;
> -	pixclock = (best->pixclock * div) / mul;		
> +	*pixclock = (best->pixclock * div) / mul;
>  }
>  			       
>  #define FAIL(X) return -EINVAL
> @@ -497,10 +497,10 @@ static int vga16fb_check_var(struct fb_var_screeninfo *var,
>  
>  	if (mode & MODE_8BPP)
>  		/* pixel clock == vga clock / 2 */
> -		vga16fb_clock_chip(par, var->pixclock, info, 1, 2);
> +		vga16fb_clock_chip(par, &var->pixclock, info, 1, 2);
>  	else
>  		/* pixel clock == vga clock */
> -		vga16fb_clock_chip(par, var->pixclock, info, 1, 1);
> +		vga16fb_clock_chip(par, &var->pixclock, info, 1, 1);
>  	
>  	var->red.offset = var->green.offset = var->blue.offset = 
>  	var->transp.offset = 0;
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2020-09-08 13:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20200723170235eucas1p21b1e0f5ff092d550d65057ae2a31a897@eucas1p2.samsung.com>
2020-07-23 17:02 ` [PATCH] video: fbdev: fix setting of pixclock because a pass-by-value error Colin King
2020-07-23 17:02   ` Colin King
2020-07-23 17:02   ` Colin King
2020-09-08 11:36   ` Bartlomiej Zolnierkiewicz
2020-09-08 11:36     ` Bartlomiej Zolnierkiewicz
2020-09-08 11:36     ` Bartlomiej Zolnierkiewicz

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.