Skip to contentSkip to conversation

sm501: unsigned ptr cannot be negative

PATCH In review roel kluin 2 participants 2 messages Nov 29, 2008 – Dec 2, 2008 Framebuffer layer

lore
Share & tools
lore

roel kluin

author
#0 lore raw

PATCH 1/1 sm501: unsigned ptr cannot be negative

unsigned ptr cannot be negative

---

drivers/video/sm501fb.c +3 -3
index f94ae84..dcd9879 100644
@@ -159,6 +159,9 @@ static int sm501_alloc_mem(struct sm501fb_info *inf, struct sm501_mem *mem,
 		break;
 
 	case SM501_MEMF_PANEL:
+		if (size > inf->fbmem_len)
+			return -ENOMEM;
+
 		ptr = inf->fbmem_len - size;
 		fbi = inf->fb[HEAD_CRT];
 
@@ -172,9 +175,6 @@ static int sm501_alloc_mem(struct sm501fb_info *inf, struct sm501_mem *mem,
 		if (fbi && ptr < fbi->fix.smem_len)
 			return -ENOMEM;
 
-		if (ptr < 0)
-			return -ENOMEM;
-
 		break;
 
 	case SM501_MEMF_CRT:
#1 lore raw
Quoted 19 lines · On Sat, 29 Nov 2008 06:49:20 -0500 roel kluin <[email protected]> wrote:

unsigned ptr cannot be negative

---

drivers/video/sm501fb.c +3 -0
index f94ae84..dcd9879 100644
@@ -159,6 +159,9 @@ static int sm501_alloc_mem(struct sm501fb_info *inf, struct sm501_mem *mem,
 		break;
 
 	case SM501_MEMF_PANEL:
+		if (size > inf->fbmem_len)
+			return -ENOMEM;
+
 		ptr = inf->fbmem_len - size;
 		fbi = inf->fb[HEAD_CRT];
 

drivers/video/sm501fb.c static int sm501_alloc_mem(struct sm501fb_info *inf, struct sm501_mem *mem, · line 180

Quoted 9 lines
drivers/video/sm501fb.c +0 -3
@@ -172,9 +175,6 @@ static int sm501_alloc_mem(struct sm501fb_info *inf, struct sm501_mem *mem,
 		if (fbi && ptr < fbi->fix.smem_len)
 			return -ENOMEM;
 
-		if (ptr < 0)
-			return -ENOMEM;
-
 		break;
 
 	case SM501_MEMF_CRT:

Looks OK.

Also this:

	if (ptr > 0)
		ptr &= ~(PAGE_SIZE - 1);

could just be

	ptr = PAGE_ALIGN(ptr);