alarmtimer: Unregister wakeup source when module get fails
authorStephen Boyd <swboyd@chromium.org>
Thu, 9 Jan 2020 15:59:07 +0000 (07:59 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Feb 2020 12:35:20 +0000 (04:35 -0800)
commitad270734193e30670516dd3b2576afcd13a389ef
tree8b923a11b10a96b7afc5e3a57a3dfb02da061cd9
parent05b147599f9d9b791a3b911734af0d944e9a7177
alarmtimer: Unregister wakeup source when module get fails

commit 6b6d188aae79a630957aefd88ff5c42af6553ee3 upstream.

The alarmtimer_rtc_add_device() function creates a wakeup source and then
tries to grab a module reference. If that fails the function returns early
with an error code, but fails to remove the wakeup source.

Cleanup this exit path so there is no dangling wakeup source, which is
named 'alarmtime' left allocated which will conflict with another RTC
device that may be registered later.

Fixes: 51218298a25e ("alarmtimer: Ensure RTC module is not unloaded")
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20200109155910.907-2-swboyd@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/time/alarmtimer.c