Skip to content

Commit

Permalink
rtc: fix coh901331 startup crash
Browse files Browse the repository at this point in the history
The rtc_device_register() call has changed semantics so that it
will immediately call out to rtc_read_alarm() and since the
callbacks require the drvdata to be set, we need to set it before
the registration call to avoid NULL dereference.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Linus Walleij committed Apr 20, 2011
1 parent cf568c5 commit 9cf3b5f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/rtc/rtc-coh901331.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,18 @@ static int __init coh901331_probe(struct platform_device *pdev)
}
clk_disable(rtap->clk);

platform_set_drvdata(pdev, rtap);
rtap->rtc = rtc_device_register("coh901331", &pdev->dev, &coh901331_ops,
THIS_MODULE);
if (IS_ERR(rtap->rtc)) {
ret = PTR_ERR(rtap->rtc);
goto out_no_rtc;
}

platform_set_drvdata(pdev, rtap);

return 0;

out_no_rtc:
platform_set_drvdata(pdev, NULL);
out_no_clk_enable:
clk_put(rtap->clk);
out_no_clk:
Expand Down

0 comments on commit 9cf3b5f

Please sign in to comment.