]> git.karo-electronics.de Git - linux-beck.git/commitdiff
drivers/video: Move dereference after NULL test
authorJulia Lawall <julia@diku.dk>
Wed, 16 Dec 2009 00:46:26 +0000 (16:46 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 16 Dec 2009 15:20:01 +0000 (07:20 -0800)
If the NULL test on fbi is needed, then the dereference should be after the
NULL test.

A simplified version of the semantic match that detects this problem is as
follows (http://coccinelle.lip6.fr/):

// <smpl>
@match exists@
expression x, E;
identifier fld;
@@

* x->fld
  ... when != \(x = E\|&x\)
* x == NULL
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Daniel Mack <daniel@caiaq.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/video/pxafb.c

index b7e58059b592fc402bb91c7f7fd5c6bbc703e41e..415858b421b3591df40f1336e7080fba7e47bbe0 100644 (file)
@@ -1221,13 +1221,14 @@ static void setup_smart_timing(struct pxafb_info *fbi,
 static int pxafb_smart_thread(void *arg)
 {
        struct pxafb_info *fbi = arg;
-       struct pxafb_mach_info *inf = fbi->dev->platform_data;
+       struct pxafb_mach_info *inf;
 
-       if (!fbi || !inf->smart_update) {
+       if (!fbi || !fbi->dev->platform_data->smart_update) {
                pr_err("%s: not properly initialized, thread terminated\n",
                                __func__);
                return -EINVAL;
        }
+       inf = fbi->dev->platform_data;
 
        pr_debug("%s(): task starting\n", __func__);