In the Linux kernel, the following vulnerability has been resolved:
rtc: cmos: Fix event handler registration ordering issue
Because acpiinstallfixedeventhandler() enables the event automatically on success, it is incorrect to call it before the handler routine passed to it is ready to handle events.
Unfortunately, the rtc-cmos driver does exactly the incorrect thing by calling cmoswakesetup(), which passes rtchandler() to acpiinstallfixedeventhandler(), before cmosdoprobe(), because rtchandler() uses devgetdrvdata() to get to the cmos object pointer and the driver data pointer is only populated in cmosdoprobe().
This leads to a NULL pointer dereference in rtc_handler() on boot if the RTC fixed event happens to be active at the init time.
To address this issue, change the initialization ordering of the driver so that cmoswakesetup() is always called after a successful cmosdoprobe() call.
While at it, change cmospnpprobe() to call cmosdoprobe() after the initial if () statement used for computing the IRQ argument to be passed to cmosdoprobe() which is cleaner than calling it in each branch of that if () (local variable "irq" can be of type int, because it is passed to that function as an argument of type int).
Note that commit 6492fed7d8c9 ("rtc: rtc-cmos: Do not check ACPIFADTLOWPOWERS0") caused this issue to affect a larger number of systems, because previously it only affected systems with ACPIFADTLOWPOWERS0 set, but it is present regardless of that commit.