Skip to content

Commit

Permalink
drivers/video: Move dereference after NULL test
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Eric Miao <[email protected]>
Cc: Daniel Mack <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Julia Lawall authored and torvalds committed Dec 16, 2009
1 parent 2f39038 commit d2a34c1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/video/pxafb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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__);

Expand Down

0 comments on commit d2a34c1

Please sign in to comment.