From: Julia Lawall Date: Wed, 16 Dec 2009 00:46:26 +0000 (-0800) Subject: drivers/video: Move dereference after NULL test X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=d2a34c1;p=linux-beck.git drivers/video: Move dereference after NULL test 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/): // @match exists@ expression x, E; identifier fld; @@ * x->fld ... when != \(x = E\|&x\) * x == NULL // Signed-off-by: Julia Lawall Cc: Krzysztof Helt Cc: Eric Miao Cc: Daniel Mack Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c index b7e58059b592..415858b421b3 100644 --- a/drivers/video/pxafb.c +++ b/drivers/video/pxafb.c @@ -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__);