From: Thierry Reding Date: Fri, 8 Aug 2014 21:20:26 +0000 (-0700) Subject: drivers/rtc/rtc-tps65910.c: fix potential NULL-pointer dereference X-Git-Tag: v3.17-rc1~73^2~160 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=9f7d7a1d0f36bed7f533807146483e8fdfe12a89;p=~emulex%2Finfiniband.git drivers/rtc/rtc-tps65910.c: fix potential NULL-pointer dereference 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). Signed-off-by: Thierry Reding Cc: Alessandro Zummo Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/rtc/rtc-tps65910.c b/drivers/rtc/rtc-tps65910.c index 7af00208d63..2583349fbde 100644 --- a/drivers/rtc/rtc-tps65910.c +++ b/drivers/rtc/rtc-tps65910.c @@ -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; }