rtc: Fix possible null pointer dereference in rtc-mpc5121.c
authorJohn Stultz <john.stultz@linaro.org>
Tue, 24 Apr 2012 20:43:35 +0000 (13:43 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 26 Apr 2012 09:17:01 +0000 (11:17 +0200)
commite48b5e825f9c471cbcbfd934a4c2df27e9d39635
tree4c2d4ce64bcd7ee61a2bbc209299f6678549f17a
parenta6371f80230eaaafd7eef7efeedaa9509bdc982d
rtc: Fix possible null pointer dereference in rtc-mpc5121.c

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>
drivers/rtc/rtc-mpc5121.c