mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 9/14] drivers/video: Move dereference after NULL test
@ 2009-10-17  6:41 Julia Lawall
  0 siblings, 0 replies; only message in thread
From: Julia Lawall @ 2009-10-17  6:41 UTC (permalink / raw)
  To: linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

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>

---
 drivers/video/pxafb.c               |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index 1820c4a..fe3172c 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -1208,13 +1208,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__);
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-10-17  6:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-17  6:41 [PATCH 9/14] drivers/video: Move dereference after NULL test Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®