Skip to content

Commit

Permalink
rtc: Fix possible null pointer dereference in rtc-mpc5121.c
Browse files Browse the repository at this point in the history
Mark Loard pointed out:
"For example, this beauty from rtc-mpc5121.c in the same update:
   ...
   rtc->rtc = rtc_device_register("mpc5200-rtc", &op->dev,
                                   &mpc5200_rtc_ops, THIS_MODULE);
   ...

   rtc->rtc->uie_unsupported = 1;    // <<<< Ooops NULL pointer >>>>

   if (IS_ERR(rtc->rtc)) {           // <<<< this needs to be earlier >>>>
           err = PTR_ERR(rtc->rtc);
           goto out_free_irq;
   }
   ..."

This patch moves setting the uie_unsupported flag to after we validate
the rtc->rtc pointer to resolve this.

Reported by: Mark Lord <kernel@teksavvy.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/1335300215-21427-1-git-send-email-john.stultz@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
John Stultz authored and Thomas Gleixner committed Apr 26, 2012
1 parent a6371f8 commit e48b5e8
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/rtc/rtc-mpc5121.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,11 @@ static int __devinit mpc5121_rtc_probe(struct platform_device *op)
&mpc5200_rtc_ops, THIS_MODULE);
}

rtc->rtc->uie_unsupported = 1;

if (IS_ERR(rtc->rtc)) {
err = PTR_ERR(rtc->rtc);
goto out_free_irq;
}
rtc->rtc->uie_unsupported = 1;

return 0;

Expand Down

0 comments on commit e48b5e8

Please sign in to comment.