Skip to content

Commit

Permalink
[PATCH] drivers/rtc/rtc-rs5c372.c: fix a NULL dereference
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Adrian Bunk authored and Linus Torvalds committed Nov 25, 2006
1 parent d728b1e commit 17ad78e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/rtc/rtc-rs5c372.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 17ad78e

Please sign in to comment.