mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] alarmtimer: ensure RTC module is not unloaded
@ 2017-08-20 22:01 Alexandre Belloni
  2017-08-21  9:42 ` Michal Simek
  2017-08-31 19:40 ` [tip:timers/core] alarmtimer: Ensure " tip-bot for Alexandre Belloni
  0 siblings, 2 replies; 3+ messages in thread
From: Alexandre Belloni @ 2017-08-20 22:01 UTC (permalink / raw)
  To: Thomas Gleixner, John Stultz
  Cc: Stephen Boyd, linux-kernel, Michal Simek, Alexandre Belloni

When registering the rtc device to be used to handle alarm timers,
get_device is used to ensure the device doesn't go away but the module can
still be unloaded. Call try_module_get to ensure the rtc driver will not go
away.

Reported-by: Michal Simek <monstr@monstr.eu>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 kernel/time/alarmtimer.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 0b8ff7d257ea..1c682eef7e6b 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -28,6 +28,7 @@
 #include <linux/workqueue.h>
 #include <linux/freezer.h>
 #include <linux/compat.h>
+#include <linux/module.h>
 
 #include "posix-timers.h"
 
@@ -100,6 +101,11 @@ static int alarmtimer_rtc_add_device(struct device *dev,
 
 	spin_lock_irqsave(&rtcdev_lock, flags);
 	if (!rtcdev) {
+		if (!try_module_get(rtc->owner)) {
+			spin_unlock_irqrestore(&rtcdev_lock, flags);
+			return -1;
+		}
+
 		rtcdev = rtc;
 		/* hold a reference so it doesn't go away */
 		get_device(dev);
-- 
2.14.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] alarmtimer: ensure RTC module is not unloaded
  2017-08-20 22:01 [PATCH] alarmtimer: ensure RTC module is not unloaded Alexandre Belloni
@ 2017-08-21  9:42 ` Michal Simek
  2017-08-31 19:40 ` [tip:timers/core] alarmtimer: Ensure " tip-bot for Alexandre Belloni
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Simek @ 2017-08-21  9:42 UTC (permalink / raw)
  To: Alexandre Belloni, Thomas Gleixner, John Stultz
  Cc: Stephen Boyd, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 1582 bytes --]

On 21.8.2017 00:01, Alexandre Belloni wrote:
> When registering the rtc device to be used to handle alarm timers,
> get_device is used to ensure the device doesn't go away but the module can
> still be unloaded. Call try_module_get to ensure the rtc driver will not go
> away.
> 
> Reported-by: Michal Simek <monstr@monstr.eu>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
>  kernel/time/alarmtimer.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
> index 0b8ff7d257ea..1c682eef7e6b 100644
> --- a/kernel/time/alarmtimer.c
> +++ b/kernel/time/alarmtimer.c
> @@ -28,6 +28,7 @@
>  #include <linux/workqueue.h>
>  #include <linux/freezer.h>
>  #include <linux/compat.h>
> +#include <linux/module.h>
>  
>  #include "posix-timers.h"
>  
> @@ -100,6 +101,11 @@ static int alarmtimer_rtc_add_device(struct device *dev,
>  
>  	spin_lock_irqsave(&rtcdev_lock, flags);
>  	if (!rtcdev) {
> +		if (!try_module_get(rtc->owner)) {
> +			spin_unlock_irqrestore(&rtcdev_lock, flags);
> +			return -1;
> +		}
> +
>  		rtcdev = rtc;
>  		/* hold a reference so it doesn't go away */
>  		get_device(dev);
> 

Tested-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal


-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP SoCs



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:timers/core] alarmtimer: Ensure RTC module is not unloaded
  2017-08-20 22:01 [PATCH] alarmtimer: ensure RTC module is not unloaded Alexandre Belloni
  2017-08-21  9:42 ` Michal Simek
@ 2017-08-31 19:40 ` tip-bot for Alexandre Belloni
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Alexandre Belloni @ 2017-08-31 19:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: monstr, hpa, alexandre.belloni, tglx, sboyd, john.stultz, mingo,
	linux-kernel

Commit-ID:  51218298a25e6942957c5595f2abf130d47d5df9
Gitweb:     http://git.kernel.org/tip/51218298a25e6942957c5595f2abf130d47d5df9
Author:     Alexandre Belloni <alexandre.belloni@free-electrons.com>
AuthorDate: Mon, 21 Aug 2017 00:01:46 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 31 Aug 2017 21:36:45 +0200

alarmtimer: Ensure RTC module is not unloaded

When registering the rtc device to be used to handle alarm timers,
get_device is used to ensure the device doesn't go away but the module can
still be unloaded.

Call try_module_get to ensure the rtc driver will not go away.

Reported-and-tested-by: Michal Simek <monstr@monstr.eu>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <john.stultz@linaro.org>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Link: http://lkml.kernel.org/r/20170820220146.30969-1-alexandre.belloni@free-electrons.com

---
 kernel/time/alarmtimer.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 73a2b47..ec09ce9 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -28,6 +28,7 @@
 #include <linux/workqueue.h>
 #include <linux/freezer.h>
 #include <linux/compat.h>
+#include <linux/module.h>
 
 #include "posix-timers.h"
 
@@ -103,6 +104,11 @@ static int alarmtimer_rtc_add_device(struct device *dev,
 
 	spin_lock_irqsave(&rtcdev_lock, flags);
 	if (!rtcdev) {
+		if (!try_module_get(rtc->owner)) {
+			spin_unlock_irqrestore(&rtcdev_lock, flags);
+			return -1;
+		}
+
 		rtcdev = rtc;
 		/* hold a reference so it doesn't go away */
 		get_device(dev);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-31 19:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-20 22:01 [PATCH] alarmtimer: ensure RTC module is not unloaded Alexandre Belloni
2017-08-21  9:42 ` Michal Simek
2017-08-31 19:40 ` [tip:timers/core] alarmtimer: Ensure " tip-bot for Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®