Skip to content

Commit e48b5e8

Browse files
johnstultz-workKAGA-KOKO
authored andcommitted
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 <[email protected]> Signed-off-by: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
1 parent a6371f8 commit e48b5e8

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/rtc/rtc-mpc5121.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,11 @@ static int __devinit mpc5121_rtc_probe(struct platform_device *op)
360360
&mpc5200_rtc_ops, THIS_MODULE);
361361
}
362362

363-
rtc->rtc->uie_unsupported = 1;
364-
365363
if (IS_ERR(rtc->rtc)) {
366364
err = PTR_ERR(rtc->rtc);
367365
goto out_free_irq;
368366
}
367+
rtc->rtc->uie_unsupported = 1;
369368

370369
return 0;
371370

0 commit comments

Comments
 (0)