]> git.baikalelectronics.ru Git - kernel.git/commit
mfd: menelaus: Fix possible race condition and leak
authorAlexandre Belloni <alexandre.belloni@bootlin.com>
Sun, 9 Sep 2018 20:48:58 +0000 (22:48 +0200)
committerLee Jones <lee.jones@linaro.org>
Tue, 11 Sep 2018 15:40:21 +0000 (16:40 +0100)
commit4c25db15f4c34e8aef4775a37bdc0361169bd578
tree2e5fa8e95045ecc72252dbe21a67c4837b6bfc82
parentf030a7bb7b1f7de16c1c716a587185e209e25800
mfd: menelaus: Fix possible race condition and leak

The IRQ work is added before the struct rtc is allocated and registered,
but this struct is used in the IRQ handler. This may lead to a NULL pointer
dereference.

Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc
before calling menelaus_add_irq_work.

Also, this solves a possible leak as the RTC is never released.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/menelaus.c