Skip to content

Commit

Permalink
drivers/rtc/rtc-tps65910.c: fix potential NULL-pointer dereference
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Alessandro Zummo <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
thierryreding authored and torvalds committed Aug 8, 2014
1 parent e1d6009 commit 9f7d7a1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/rtc/rtc-tps65910.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -283,8 +285,6 @@ static int tps65910_rtc_probe(struct platform_device *pdev)
return ret;
}

platform_set_drvdata(pdev, tps_rtc);

return 0;
}

Expand Down

0 comments on commit 9f7d7a1

Please sign in to comment.