sm501: unsigned ptr cannot be negative
authorroel kluin <roel.kluin@gmail.com>
Tue, 6 Jan 2009 22:42:36 +0000 (14:42 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 6 Jan 2009 23:59:27 +0000 (15:59 -0800)
unsigned ptr cannot be negative

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Cc: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/video/sm501fb.c

index f94ae84a58cd54eabd267a9e4d33384b346755ec..dcd98793d5681e14e7521e1f9efcf92806fe4f8b 100644 (file)
@@ -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: