mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/5] watchdog: Set missing .owner = THIS_MODULE in watchdog_ops
@ 2026-11-30 22:54 Ian Rogers
  2026-11-30 22:54 ` [PATCH 1/5] watchdog: arm_smc_wdt: Set " Ian Rogers
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Ian Rogers @ 2026-11-30 22:54 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: Nathan Chancellor, linux-watchdog, llvm, linux-kernel, Ian Rogers

watchdog_open() calls try_module_get(wdd->ops->owner) so a modular
watchdog driver cannot be unloaded while /dev/watchdog is open. Five
modular watchdog drivers omit .owner = THIS_MODULE in their const struct
watchdog_ops definitions, leaving wdd->ops->owner NULL.

Split per driver to simplify review and stable backporting.

Tooling note: Found using Clang's require_explicit_initialization
attribute; an AI coding assistant helped audit call sites, verify Fixes
commits, and draft the changelogs. All five drivers were build-tested as
modules (-DMODULE) with LLVM=1.

Ian Rogers (5):
  watchdog: arm_smc_wdt: Set .owner = THIS_MODULE in watchdog_ops
  watchdog: bd96801_wdt: Set .owner = THIS_MODULE in watchdog_ops
  watchdog: ebc-c384_wdt: Set .owner = THIS_MODULE in watchdog_ops
  watchdog: max77620: Set .owner = THIS_MODULE in watchdog_ops
  watchdog: meson_gxbb_wdt: Set .owner = THIS_MODULE in watchdog_ops

 drivers/watchdog/arm_smc_wdt.c    | 2 ++
 drivers/watchdog/bd96801_wdt.c    | 1 +
 drivers/watchdog/ebc-c384_wdt.c   | 1 +
 drivers/watchdog/max77620_wdt.c   | 1 +
 drivers/watchdog/meson_gxbb_wdt.c | 1 +
 5 files changed, 6 insertions(+)


base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
-- 
2.56.1.839.g22a8290db9-goog


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

* [PATCH 1/5] watchdog: arm_smc_wdt: Set .owner = THIS_MODULE in watchdog_ops
  2026-11-30 22:54 [PATCH 0/5] watchdog: Set missing .owner = THIS_MODULE in watchdog_ops Ian Rogers
@ 2026-11-30 22:54 ` Ian Rogers
  2026-11-30 22:54 ` [PATCH 2/5] watchdog: bd96801_wdt: " Ian Rogers
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ian Rogers @ 2026-11-30 22:54 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: Nathan Chancellor, linux-watchdog, llvm, linux-kernel,
	Ian Rogers, Julius Werner, Evan Benn, Antonio Borneo

watchdog_open() calls try_module_get(wdd->ops->owner) to prevent the
watchdog driver module from being unloaded while /dev/watchdog is open,
and watchdog_release() calls module_put(wdd->ops->owner). Because
try_module_get(NULL) succeeds without incrementing any module reference
count, omitting .owner = THIS_MODULE allows the module to be unloaded
while the watchdog character device is open.

Set .owner = THIS_MODULE in smcwd_ops and smcwd_timeleft_ops, found with
Clang's require_explicit_initialization attribute.

Fixes: 72a9e7fea586 ("watchdog: Add new arm_smc_wdt watchdog driver")
Fixes: cc0df5eba1b3 ("watchdog: arm_smc_wdt: get wdt status through SMCWD_GET_TIMELEFT")
Signed-off-by: Ian Rogers <irogers@google.com>
---
 drivers/watchdog/arm_smc_wdt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/watchdog/arm_smc_wdt.c b/drivers/watchdog/arm_smc_wdt.c
index 479863450a9c..e593ee8f23c0 100644
--- a/drivers/watchdog/arm_smc_wdt.c
+++ b/drivers/watchdog/arm_smc_wdt.c
@@ -97,6 +97,7 @@ static const struct watchdog_info smcwd_info = {
 };
 
 static const struct watchdog_ops smcwd_ops = {
+	.owner		= THIS_MODULE,
 	.start		= smcwd_start,
 	.stop		= smcwd_stop,
 	.ping		= smcwd_ping,
@@ -104,6 +105,7 @@ static const struct watchdog_ops smcwd_ops = {
 };
 
 static const struct watchdog_ops smcwd_timeleft_ops = {
+	.owner		= THIS_MODULE,
 	.start		= smcwd_start,
 	.stop		= smcwd_stop,
 	.ping		= smcwd_ping,
-- 
2.56.1.839.g22a8290db9-goog


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

* [PATCH 2/5] watchdog: bd96801_wdt: Set .owner = THIS_MODULE in watchdog_ops
  2026-11-30 22:54 [PATCH 0/5] watchdog: Set missing .owner = THIS_MODULE in watchdog_ops Ian Rogers
  2026-11-30 22:54 ` [PATCH 1/5] watchdog: arm_smc_wdt: Set " Ian Rogers
@ 2026-11-30 22:54 ` Ian Rogers
  2026-11-30 22:54 ` [PATCH 3/5] watchdog: ebc-c384_wdt: " Ian Rogers
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ian Rogers @ 2026-11-30 22:54 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: Nathan Chancellor, linux-watchdog, llvm, linux-kernel,
	Ian Rogers, Matti Vaittinen, Lee Jones

watchdog_open() calls try_module_get(wdd->ops->owner) to prevent the
watchdog driver module from being unloaded while /dev/watchdog is open,
and watchdog_release() calls module_put(wdd->ops->owner). Because
try_module_get(NULL) succeeds without incrementing any module reference
count, omitting .owner = THIS_MODULE allows the module to be unloaded
while the watchdog character device is open.

Set .owner = THIS_MODULE in bd96801_wdt_ops, found with Clang's
require_explicit_initialization attribute.

Fixes: 09dad69757b6 ("watchdog: ROHM BD96801 PMIC WDG driver")
Signed-off-by: Ian Rogers <irogers@google.com>
---
 drivers/watchdog/bd96801_wdt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/watchdog/bd96801_wdt.c b/drivers/watchdog/bd96801_wdt.c
index ce93a900b0be..38d14b22b09d 100644
--- a/drivers/watchdog/bd96801_wdt.c
+++ b/drivers/watchdog/bd96801_wdt.c
@@ -94,6 +94,7 @@ static const struct watchdog_info bd96801_wdt_info = {
 };
 
 static const struct watchdog_ops bd96801_wdt_ops = {
+	.owner		= THIS_MODULE,
 	.start		= bd96801_wdt_start,
 	.stop		= bd96801_wdt_stop,
 	.ping		= bd96801_wdt_ping,
-- 
2.56.1.839.g22a8290db9-goog


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

* [PATCH 3/5] watchdog: ebc-c384_wdt: Set .owner = THIS_MODULE in watchdog_ops
  2026-11-30 22:54 [PATCH 0/5] watchdog: Set missing .owner = THIS_MODULE in watchdog_ops Ian Rogers
  2026-11-30 22:54 ` [PATCH 1/5] watchdog: arm_smc_wdt: Set " Ian Rogers
  2026-11-30 22:54 ` [PATCH 2/5] watchdog: bd96801_wdt: " Ian Rogers
@ 2026-11-30 22:54 ` Ian Rogers
  2026-11-30 22:54 ` [PATCH 4/5] watchdog: max77620: " Ian Rogers
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ian Rogers @ 2026-11-30 22:54 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: Nathan Chancellor, linux-watchdog, llvm, linux-kernel,
	Ian Rogers, William Breathitt Gray

watchdog_open() calls try_module_get(wdd->ops->owner) to prevent the
watchdog driver module from being unloaded while /dev/watchdog is open,
and watchdog_release() calls module_put(wdd->ops->owner). Because
try_module_get(NULL) succeeds without incrementing any module reference
count, omitting .owner = THIS_MODULE allows the module to be unloaded
while the watchdog character device is open.

Set .owner = THIS_MODULE in ebc_c384_wdt_ops, found with Clang's
require_explicit_initialization attribute.

Fixes: c36a483d8007 ("watchdog: Add watchdog timer support for the WinSystems EBC-C384")
Signed-off-by: Ian Rogers <irogers@google.com>
---
 drivers/watchdog/ebc-c384_wdt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/watchdog/ebc-c384_wdt.c b/drivers/watchdog/ebc-c384_wdt.c
index c80a28b09de0..e931f43bcc3f 100644
--- a/drivers/watchdog/ebc-c384_wdt.c
+++ b/drivers/watchdog/ebc-c384_wdt.c
@@ -78,6 +78,7 @@ static int ebc_c384_wdt_set_timeout(struct watchdog_device *wdev, unsigned t)
 }
 
 static const struct watchdog_ops ebc_c384_wdt_ops = {
+	.owner = THIS_MODULE,
 	.start = ebc_c384_wdt_start,
 	.stop = ebc_c384_wdt_stop,
 	.set_timeout = ebc_c384_wdt_set_timeout
-- 
2.56.1.839.g22a8290db9-goog


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

* [PATCH 4/5] watchdog: max77620: Set .owner = THIS_MODULE in watchdog_ops
  2026-11-30 22:54 [PATCH 0/5] watchdog: Set missing .owner = THIS_MODULE in watchdog_ops Ian Rogers
                   ` (2 preceding siblings ...)
  2026-11-30 22:54 ` [PATCH 3/5] watchdog: ebc-c384_wdt: " Ian Rogers
@ 2026-11-30 22:54 ` Ian Rogers
  2026-11-30 22:54 ` [PATCH 5/5] watchdog: meson_gxbb_wdt: " Ian Rogers
  2026-11-30 23:10 ` [PATCH 0/5] watchdog: Set missing " Guenter Roeck
  5 siblings, 0 replies; 7+ messages in thread
From: Ian Rogers @ 2026-11-30 22:54 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: Nathan Chancellor, linux-watchdog, llvm, linux-kernel,
	Ian Rogers, Laxman Dewangan

watchdog_open() calls try_module_get(wdd->ops->owner) to prevent the
watchdog driver module from being unloaded while /dev/watchdog is open,
and watchdog_release() calls module_put(wdd->ops->owner). Because
try_module_get(NULL) succeeds without incrementing any module reference
count, omitting .owner = THIS_MODULE allows the module to be unloaded
while the watchdog character device is open.

Set .owner = THIS_MODULE in max77620_wdt_ops, found with Clang's
require_explicit_initialization attribute.

Fixes: ff3bb2f5c3cd ("watchdog: max77620: Add support for watchdog timer")
Signed-off-by: Ian Rogers <irogers@google.com>
---
 drivers/watchdog/max77620_wdt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/watchdog/max77620_wdt.c b/drivers/watchdog/max77620_wdt.c
index 4fc8a858d221..ad2b497f7c9a 100644
--- a/drivers/watchdog/max77620_wdt.c
+++ b/drivers/watchdog/max77620_wdt.c
@@ -148,6 +148,7 @@ static const struct watchdog_info max77620_wdt_info = {
 };
 
 static const struct watchdog_ops max77620_wdt_ops = {
+	.owner		= THIS_MODULE,
 	.start		= max77620_wdt_start,
 	.stop		= max77620_wdt_stop,
 	.ping		= max77620_wdt_ping,
-- 
2.56.1.839.g22a8290db9-goog


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

* [PATCH 5/5] watchdog: meson_gxbb_wdt: Set .owner = THIS_MODULE in watchdog_ops
  2026-11-30 22:54 [PATCH 0/5] watchdog: Set missing .owner = THIS_MODULE in watchdog_ops Ian Rogers
                   ` (3 preceding siblings ...)
  2026-11-30 22:54 ` [PATCH 4/5] watchdog: max77620: " Ian Rogers
@ 2026-11-30 22:54 ` Ian Rogers
  2026-11-30 23:10 ` [PATCH 0/5] watchdog: Set missing " Guenter Roeck
  5 siblings, 0 replies; 7+ messages in thread
From: Ian Rogers @ 2026-11-30 22:54 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: Nathan Chancellor, linux-watchdog, llvm, linux-kernel,
	Ian Rogers, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, linux-arm-kernel, linux-amlogic

watchdog_open() calls try_module_get(wdd->ops->owner) to prevent the
watchdog driver module from being unloaded while /dev/watchdog is open,
and watchdog_release() calls module_put(wdd->ops->owner). Because
try_module_get(NULL) succeeds without incrementing any module reference
count, omitting .owner = THIS_MODULE allows the module to be unloaded
while the watchdog character device is open.

Set .owner = THIS_MODULE in meson_gxbb_wdt_ops, found with Clang's
require_explicit_initialization attribute.

Fixes: 683fa50f0e18 ("watchdog: Add Meson GXBB Watchdog Driver")
Signed-off-by: Ian Rogers <irogers@google.com>
---
 drivers/watchdog/meson_gxbb_wdt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c
index a88fe8cbeef5..7ee8632eba36 100644
--- a/drivers/watchdog/meson_gxbb_wdt.c
+++ b/drivers/watchdog/meson_gxbb_wdt.c
@@ -108,6 +108,7 @@ static unsigned int meson_gxbb_wdt_get_timeleft(struct watchdog_device *wdt_dev)
 }
 
 static const struct watchdog_ops meson_gxbb_wdt_ops = {
+	.owner = THIS_MODULE,
 	.start = meson_gxbb_wdt_start,
 	.stop = meson_gxbb_wdt_stop,
 	.ping = meson_gxbb_wdt_ping,
-- 
2.56.1.839.g22a8290db9-goog


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

* Re: [PATCH 0/5] watchdog: Set missing .owner = THIS_MODULE in watchdog_ops
  2026-11-30 22:54 [PATCH 0/5] watchdog: Set missing .owner = THIS_MODULE in watchdog_ops Ian Rogers
                   ` (4 preceding siblings ...)
  2026-11-30 22:54 ` [PATCH 5/5] watchdog: meson_gxbb_wdt: " Ian Rogers
@ 2026-11-30 23:10 ` Guenter Roeck
  5 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2026-11-30 23:10 UTC (permalink / raw)
  To: Ian Rogers, Wim Van Sebroeck
  Cc: Nathan Chancellor, linux-watchdog, llvm, linux-kernel

Hi Ian,

On 11/30/26 14:54, Ian Rogers wrote:
> watchdog_open() calls try_module_get(wdd->ops->owner) so a modular
> watchdog driver cannot be unloaded while /dev/watchdog is open. Five
> modular watchdog drivers omit .owner = THIS_MODULE in their const struct
> watchdog_ops definitions, leaving wdd->ops->owner NULL.
> 
> Split per driver to simplify review and stable backporting.
> 
> Tooling note: Found using Clang's require_explicit_initialization
> attribute; an AI coding assistant helped audit call sites, verify Fixes
> commits, and draft the changelogs. All five drivers were build-tested as
> modules (-DMODULE) with LLVM=1.
> 
> Ian Rogers (5):
>    watchdog: arm_smc_wdt: Set .owner = THIS_MODULE in watchdog_ops
>    watchdog: bd96801_wdt: Set .owner = THIS_MODULE in watchdog_ops
>    watchdog: ebc-c384_wdt: Set .owner = THIS_MODULE in watchdog_ops
>    watchdog: max77620: Set .owner = THIS_MODULE in watchdog_ops
>    watchdog: meson_gxbb_wdt: Set .owner = THIS_MODULE in watchdog_ops

Series applied. Note that I dropped the second Fixes: tag from the first
patch as suggested by Sashiko.

Thanks,
Guenter


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

end of thread, other threads:[~2026-11-30 23:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 22:54 [PATCH 0/5] watchdog: Set missing .owner = THIS_MODULE in watchdog_ops Ian Rogers
2026-11-30 22:54 ` [PATCH 1/5] watchdog: arm_smc_wdt: Set " Ian Rogers
2026-11-30 22:54 ` [PATCH 2/5] watchdog: bd96801_wdt: " Ian Rogers
2026-11-30 22:54 ` [PATCH 3/5] watchdog: ebc-c384_wdt: " Ian Rogers
2026-11-30 22:54 ` [PATCH 4/5] watchdog: max77620: " Ian Rogers
2026-11-30 22:54 ` [PATCH 5/5] watchdog: meson_gxbb_wdt: " Ian Rogers
2026-11-30 23:10 ` [PATCH 0/5] watchdog: Set missing " Guenter Roeck

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®