linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] video: fbdev: uvesafb.c:  Added additional error checking
@ 2014-07-23 21:20 Rickard Strandqvist
  2014-07-24 17:31 ` Wang YanQing
  2014-07-24 17:36 ` Wang YanQing
  0 siblings, 2 replies; 4+ messages in thread
From: Rickard Strandqvist @ 2014-07-23 21:20 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen
  Cc: Rickard Strandqvist, Wang YanQing, Jingoo Han, David Fries,
	Greg Kroah-Hartman, Joe Perches, linux-fbdev, linux-kernel

Variable was assigned a value that is never used.
Now the variable is used, and the function returns if a call to
uvesafb_exec() returns a error.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
 drivers/video/fbdev/uvesafb.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
index 509d452..47c2d74 100644
--- a/drivers/video/fbdev/uvesafb.c
+++ b/drivers/video/fbdev/uvesafb.c
@@ -561,6 +561,8 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
 	task->t.regs.eax = 0x4f0a;
 	task->t.regs.ebx = 0x0;
 	err = uvesafb_exec(task);
+	if (err)
+		return err;
 
 	if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
 		par->pmi_setpal = par->ypan = 0;
-- 
1.7.10.4


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

* Re: [PATCH v2] video: fbdev: uvesafb.c:  Added additional error checking
  2014-07-23 21:20 [PATCH v2] video: fbdev: uvesafb.c: Added additional error checking Rickard Strandqvist
@ 2014-07-24 17:31 ` Wang YanQing
  2014-07-24 17:36 ` Wang YanQing
  1 sibling, 0 replies; 4+ messages in thread
From: Wang YanQing @ 2014-07-24 17:31 UTC (permalink / raw)
  To: Rickard Strandqvist
  Cc: Jean-Christophe Plagniol-Villard, Tomi Valkeinen, Jingoo Han,
	David Fries, Greg Kroah-Hartman, Joe Perches, linux-fbdev,
	linux-kernel

On Wed, Jul 23, 2014 at 11:20:27PM +0200, Rickard Strandqvist wrote:
> Variable was assigned a value that is never used.
> Now the variable is used, and the function returns if a call to
> uvesafb_exec() returns a error.

Because the only user of uvesafb_vbe_getpmi in uvesafb.c
don't check its return value, it should do the check indeed,
so maybe below change is better:

-       if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
+       if (err || (task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
                par->pmi_setpal = par->ypan = 0;
        }

Or we check uvesafb_vbe_getpmi's return value, then the code will looks like below:

if (uvesafb_vbe_getpmi(task, par))
    par->pmi_setpal = par->ypan = 0;


Thanks.

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

* Re: [PATCH v2] video: fbdev: uvesafb.c:  Added additional error checking
  2014-07-23 21:20 [PATCH v2] video: fbdev: uvesafb.c: Added additional error checking Rickard Strandqvist
  2014-07-24 17:31 ` Wang YanQing
@ 2014-07-24 17:36 ` Wang YanQing
  2014-07-26 10:19   ` Rickard Strandqvist
  1 sibling, 1 reply; 4+ messages in thread
From: Wang YanQing @ 2014-07-24 17:36 UTC (permalink / raw)
  To: Rickard Strandqvist
  Cc: Jean-Christophe Plagniol-Villard, Tomi Valkeinen, Jingoo Han,
	David Fries, Greg Kroah-Hartman, Joe Perches, linux-fbdev,
	linux-kernel, pavel

On Wed, Jul 23, 2014 at 11:20:27PM +0200, Rickard Strandqvist wrote:
> Variable was assigned a value that is never used.
> Now the variable is used, and the function returns if a call to
> uvesafb_exec() returns a error.

Because the only user of uvesafb_vbe_getpmi in uvesafb.c
don't check its return value, it should do the check indeed,
so maybe below change is better:

-       if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
+       if (err || (task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
                par->pmi_setpal = par->ypan = 0;
        }

Or we check uvesafb_vbe_getpmi's return value, then the code will looks like below:

if (uvesafb_vbe_getpmi(task, par))
    par->pmi_setpal = par->ypan = 0;


Add cc:pavel@ucw.cz, you should cc all the people who replied your patch 
in later patch version.

Thanks.

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

* Re: [PATCH v2] video: fbdev: uvesafb.c: Added additional error checking
  2014-07-24 17:36 ` Wang YanQing
@ 2014-07-26 10:19   ` Rickard Strandqvist
  0 siblings, 0 replies; 4+ messages in thread
From: Rickard Strandqvist @ 2014-07-26 10:19 UTC (permalink / raw)
  To: Wang YanQing, Rickard Strandqvist,
	Jean-Christophe Plagniol-Villard, Tomi Valkeinen, Jingoo Han,
	David Fries, Greg Kroah-Hartman, Joe Perches,
	Linux Fbdev development list, linux-kernel@vger.kernel.org,
	Pavel Machek

2014-07-24 19:36 GMT+02:00 Wang YanQing <udknight@gmail.com>:
> On Wed, Jul 23, 2014 at 11:20:27PM +0200, Rickard Strandqvist wrote:
>> Variable was assigned a value that is never used.
>> Now the variable is used, and the function returns if a call to
>> uvesafb_exec() returns a error.
>
> Because the only user of uvesafb_vbe_getpmi in uvesafb.c
> don't check its return value, it should do the check indeed,
> so maybe below change is better:
>
> -       if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
> +       if (err || (task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
>                 par->pmi_setpal = par->ypan = 0;
>         }
>
> Or we check uvesafb_vbe_getpmi's return value, then the code will looks like below:
>
> if (uvesafb_vbe_getpmi(task, par))
>     par->pmi_setpal = par->ypan = 0;


Hi

Sure, I saw that much of the other code using something like:
if (err || ...)


But this whole discussion start with that you wished it would return
the error, and then error code I assumed?

Ok, but something like this then?

err = uvesafb_exec(task);
if (err) {
  par->pmi_setpal = par->ypan = 0;
  return err;
}


Kind regards
Rickard Strandqvist

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

end of thread, other threads:[~2014-07-26 10:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-23 21:20 [PATCH v2] video: fbdev: uvesafb.c: Added additional error checking Rickard Strandqvist
2014-07-24 17:31 ` Wang YanQing
2014-07-24 17:36 ` Wang YanQing
2014-07-26 10:19   ` Rickard Strandqvist

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).