Skip to contentSkip to conversation

drivers/rtc/rtc-rs5c372.c: fix a NULL dereference

PATCH New Adrian Bunk 1 participant 1 message Nov 17, 2006 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/rtc/rtc-rs5c372.c: fix a NULL dereference

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.

drivers/rtc/rtc-rs5c372.c renamed from drivers/rtc/rtc-rs5c372.c.old +3 -3
@@ -126,13 +126,13 @@ static int rs5c372_get_trim(struct i2c_c
 		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;
 }