Re: [PATCH 2/5] watchdog: bd96801_wdt: Set .owner = THIS_MODULE in watchdog_ops

From: Matti Vaittinen

Date: Tue Dec 01 2026 - 03:03:49 EST


On 01/12/2026 00:54, Ian Rogers wrote:
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@xxxxxxxxxx>

Reviewed-by: Matti Vaittinen <mazziesaccount@xxxxxxxxx>

Thanks a lot!

This made me wonder, would it be possible to do some macro-magic so the .owner was automatically set upon driver registration to wdg-core, when driver is built as a module?

Yours,
-- Matti

--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductor
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~