Skip to contentSkip to conversation

video/smscufx: fix line counting in fb_write

PATCH In review Alexander Holler 2 participants 6 messages Apr 20, 2012 – Jul 30, 2012 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 video/smscufx: fix line counting in fb_write

Line 0 and 1 were both written to line 0 (on the display) and all subsequent lines had an offset of -1. The result was that the last line on the display was never overwritten by writes to /dev/fbN.

The origin of this bug seems to have been udlfb.

---
 drivers/video/smscufx.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/video/smscufx.c +1 -1
index ccbfef5..1e1e2d2 100644
@@ -904,7 +904,7 @@ static ssize_t ufx_ops_write(struct fb_info *info, const char __user *buf,
 	result = fb_sys_write(info, buf, count, ppos);
 
 	if (result > 0) {
-		int start = max((int)(offset / info->fix.line_length) - 1, 0);
+		int start = max((int)(offset / info->fix.line_length), 0);
 		int lines = min((u32)((result / info->fix.line_length) + 1),
 				(u32)info->var.yres);
 
Signature · 1 line
1.7.6.5
#1 lore raw

Hello,

as for the patch for udlfb, I forgot to mention that this is a candidate for all stable trees 3.2 and above.

Btw., the address of the maintainer doesn't seem to be valid anymore.

Regards,

Alexander

Am 21.04.2012 00:11, schrieb Alexander Holler:

Quoted 7 lines

Line 0 and 1 were both written to line 0 (on the display) and all subsequent lines had an offset of -1. The result was that the last line on the display was never overwritten by writes to /dev/fbN.

The origin of this bug seems to have been udlfb.

Quoted 17 lines
---
  drivers/video/smscufx.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
drivers/video/smscufx.c +1 -1
index ccbfef5..1e1e2d2 100644
@@ -904,7 +904,7 @@ static ssize_t ufx_ops_write(struct fb_info *info, const char __user *buf,
  	result = fb_sys_write(info, buf, count, ppos);
 
  	if (result>  0) {
-		int start = max((int)(offset / info->fix.line_length) - 1, 0);
+		int start = max((int)(offset / info->fix.line_length), 0);
  		int lines = min((u32)((result / info->fix.line_length) + 1),
  				(u32)info->var.yres);
 
#2 lore raw

Hi Alexander,

Quoted 6 lines · Alexander Holler

Hello,

as for the patch for udlfb, I forgot to mention that this is a candidate for all stable trees 3.2 and above.

Btw., the address of the maintainer doesn't seem to be valid anymore.

it is better to cc me on patches to the framebuffer subsystem for such cases. I don't have much free time so it's rare that I come around to dig in the mailing list.

Quoted 12 lines

Regards,

Alexander

Am 21.04.2012 00:11, schrieb Alexander Holler:

Quoted 6 lines

Line 0 and 1 were both written to line 0 (on the display) and all subsequent
lines had an offset of -1. The result was that the last line on the display
was never overwritten by writes to /dev/fbN.

Quoted 5 lines
Quoted 3 lines

The origin of this bug seems to have been udlfb.

Patch looks good to me but can be made simpler.

Quoted 13 lines
Quoted 13 lines
---
  drivers/video/smscufx.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
drivers/video/smscufx.c +0 -0
index ccbfef5..1e1e2d2 100644
@@ -904,7 +904,7 @@ static ssize_t ufx_ops_write(struct fb_info *info,
 const char __user *buf,
      result = fb_sys_write(info, buf, count, ppos);
 
Quoted 3 lines

drivers/video/smscufx.c static ssize_t ufx_ops_write(struct fb_info *info, const char __user *buf, · line 907

Quoted 3 lines
drivers/video/smscufx.c +1 -1
      if (result>  0) {
-        int start = max((int)(offset / info->fix.line_length) - 1, 0);
+        int start = max((int)(offset / info->fix.line_length), 0);

the cast to int as well as the max is superfluous without the -1 as the value can no longer be negative.

Quoted 4 lines

drivers/video/smscufx.c static ssize_t ufx_ops_write(struct fb_info *info, const char __user *buf, · line 909

Quoted 3 lines
drivers/video/smscufx.c +0 -0
          int lines = min((u32)((result / info->fix.line_length) + 1),
                  (u32)info->var.yres);

Best regards,

Florian Tobias Schandinat

#3 lore raw

Hi Florian,

sorry for the late answer.

Am 13.05.2012 14:47, schrieb Florian Tobias Schandinat:

Quoted 47 lines

Hi Alexander,

Quoted 6 lines · Alexander Holler

Hello,

as for the patch for udlfb, I forgot to mention that this is a candidate for all stable trees 3.2 and above.

Btw., the address of the maintainer doesn't seem to be valid anymore.

it is better to cc me on patches to the framebuffer subsystem for such cases. I don't have much free time so it's rare that I come around to dig in the mailing list.

Quoted 12 lines

Regards,

Alexander

Am 21.04.2012 00:11, schrieb Alexander Holler:

Quoted 6 lines

Line 0 and 1 were both written to line 0 (on the display) and all subsequent
lines had an offset of -1. The result was that the last line on the display
was never overwritten by writes to /dev/fbN.

Quoted 5 lines
Quoted 3 lines

The origin of this bug seems to have been udlfb.

Patch looks good to me but can be made simpler.

Quoted 13 lines
Quoted 13 lines
---
   drivers/video/smscufx.c |    2 +-
   1 files changed, 1 insertions(+), 1 deletions(-)
drivers/video/smscufx.c +0 -0
index ccbfef5..1e1e2d2 100644
@@ -904,7 +904,7 @@ static ssize_t ufx_ops_write(struct fb_info *info,
 const char __user *buf,
       result = fb_sys_write(info, buf, count, ppos);
 
Quoted 6 lines
Quoted 3 lines

drivers/video/smscufx.c static ssize_t ufx_ops_write(struct fb_info *info, const char __user *buf, · line 907

Quoted 3 lines
drivers/video/smscufx.c +1 -1
       if (result>  0) {
-        int start = max((int)(offset / info->fix.line_length) - 1, 0);
+        int start = max((int)(offset / info->fix.line_length), 0);

the cast to int as well as the max is superfluous without the -1 as the value can no longer be negative.

I had that impression too, but I wanted to change as less as possible, so I didn't had the need to check types and (their) sizes for possible overflows or such. I was lazy and just wanted to fix that one bug. ;)

Quoted 4 lines
Quoted 4 lines

drivers/video/smscufx.c static ssize_t ufx_ops_write(struct fb_info *info, const char __user *buf, · line 909

Quoted 4 lines
drivers/video/smscufx.c +0 -0
           int lines = min((u32)((result / info->fix.line_length) + 1),
                   (u32)info->var.yres);

Regards,

Alexander

#4 lore raw
Quoted 59 lines · Alexander Holler

Hi Florian,

sorry for the late answer.

Am 13.05.2012 14:47, schrieb Florian Tobias Schandinat:

Quoted 47 lines

Hi Alexander,

Quoted 6 lines · Alexander Holler

Hello,

as for the patch for udlfb, I forgot to mention that this is a candidate for all stable trees 3.2 and above.

Btw., the address of the maintainer doesn't seem to be valid anymore.

it is better to cc me on patches to the framebuffer subsystem for such cases. I don't have much free time so it's rare that I come around to dig in the mailing list.

Quoted 12 lines

Regards,

Alexander

Am 21.04.2012 00:11, schrieb Alexander Holler:

Quoted 6 lines

Line 0 and 1 were both written to line 0 (on the display) and all subsequent
lines had an offset of -1. The result was that the last line on the display
was never overwritten by writes to /dev/fbN.

Quoted 5 lines
Quoted 3 lines

The origin of this bug seems to have been udlfb.

Patch looks good to me but can be made simpler.

Quoted 13 lines
Quoted 13 lines
---
   drivers/video/smscufx.c |    2 +-
   1 files changed, 1 insertions(+), 1 deletions(-)
drivers/video/smscufx.c +0 -0
index ccbfef5..1e1e2d2 100644
@@ -904,7 +904,7 @@ static ssize_t ufx_ops_write(struct fb_info *info,
 const char __user *buf,
       result = fb_sys_write(info, buf, count, ppos);
 
Quoted 6 lines
Quoted 3 lines

drivers/video/smscufx.c static ssize_t ufx_ops_write(struct fb_info *info, const char __user *buf, · line 907

Quoted 3 lines
drivers/video/smscufx.c +1 -1
       if (result>  0) {
-        int start = max((int)(offset / info->fix.line_length) - 1, 0);
+        int start = max((int)(offset / info->fix.line_length), 0);

the cast to int as well as the max is superfluous without the -1 as the value can no longer be negative.

Quoted 3 lines

I had that impression too, but I wanted to change as less as possible, so I didn't had the need to check types and (their) sizes for possible overflows or such. I was lazy and just wanted to fix that one bug. ;)

Well, as this patch fixes a bug I applied it as is.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/video/smscufx.c static ssize_t ufx_ops_write(struct fb_info *info, const char __user *buf, · line 909

Quoted 5 lines
drivers/video/smscufx.c +0 -0
           int lines = min((u32)((result / info->fix.line_length) + 1),
                   (u32)info->var.yres);

Best regards,

Florian Tobias Schandinat

#5 lore raw

Hello,

Am 26.07.2012 19:26, schrieb Florian Tobias Schandinat:

Quoted 1 line

Well, as this patch fixes a bug I applied it as is.

Thanks a lot, actually I was more interested to get that one-line-patch for udlfb, because I've discovered that bug using one of those Mimo-LCDs. ;)

Are you responsible for that too?

Regards,

Alexander