Skip to contentSkip to conversation

rtc: tps65910: Fix potential NULL-pointer dereference

PATCH New Thierry Reding 1 participant 1 message Aug 5, 2014 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: tps65910: Fix potential NULL-pointer dereference

From: Thierry Reding <[email protected]>

The interrupt handler gets the driver data associated with the RTC device and doesn't check it for validity. This can cause a NULL pointer being dereferenced when and interrupt fires before the driver data was properly set up.

Fix this by setting the driver data earlier (before the interrupt is requested).

---
 drivers/rtc/rtc-tps65910.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-tps65910.c +2 -2
index 7af00208d637..2583349fbde5 100644
@@ -258,6 +258,8 @@ static int tps65910_rtc_probe(struct platform_device *pdev)
 	if (ret < 0)
 		return ret;
 
+	platform_set_drvdata(pdev, tps_rtc);
+
 	irq  = platform_get_irq(pdev, 0);
 	if (irq <= 0) {
 		dev_warn(&pdev->dev, "Wake up is not possible as irq = %d\n",
@@ -283,8 +285,6 @@ static int tps65910_rtc_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	platform_set_drvdata(pdev, tps_rtc);
-
 	return 0;
 }
 
Signature · 1 line
2.0.4