[PATCH] drivers/rtc/rtc-rs5c372.c: fix a NULL dereference
authorAdrian Bunk <bunk@stusta.de>
Sat, 25 Nov 2006 19:09:29 +0000 (11:09 -0800)
committerLinus Torvalds <torvalds@woody.osdl.org>
Sat, 25 Nov 2006 21:28:33 +0000 (13:28 -0800)
The correct order is: NULL check before dereference

This was a guaranteed NULL dereference with debugging enabled since
rs5c372_sysfs_show_osc() does actually pass NULL...

Spotted by the Coverity checker.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Acked-by: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/rtc/rtc-rs5c372.c

index 2a86632580f16e2cc0d010fb938af67c6df81be8..a44fe4efa216ac372cc8eac8d4e0d18aa6c9a71d 100644 (file)
@@ -126,13 +126,13 @@ static int rs5c372_get_trim(struct i2c_client *client, int *osc, int *trim)
                return -EIO;
        }
 
-       dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, *trim);
-
        if (osc)
                *osc = (buf & RS5C372_TRIM_XSL) ? 32000 : 32768;
 
-       if (trim)
+       if (trim) {
                *trim = buf & RS5C372_TRIM_MASK;
+               dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, *trim);
+       }
 
        return 0;
 }