* [PATCH] watchdog: core: assign parent with devm registration
@ 2026-05-24 2:23 Rosen Penev
2026-05-24 15:22 ` Guenter Roeck
0 siblings, 1 reply; 3+ messages in thread
From: Rosen Penev @ 2026-05-24 2:23 UTC (permalink / raw)
To: linux-watchdog; +Cc: Wim Van Sebroeck, linusw, Guenter Roeck, open list
If the user did not pass a parent in the struct watchdog_device
then use the device used for devres as parent.
This is quite intuitive and can help avoiding having to
assign parent explicitly in every driver using devres
to add the watchdog_device.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
Linus: hope you don't mind me flat out copying the description from
https://lore.kernel.org/all/20260427-gpio-mmio-more-v3-1-fe1882351424@kernel.org/
drivers/watchdog/watchdog_core.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
index 8300520688d0..726c85debabc 100644
--- a/drivers/watchdog/watchdog_core.c
+++ b/drivers/watchdog/watchdog_core.c
@@ -440,6 +440,13 @@ int devm_watchdog_register_device(struct device *dev,
if (!rcwdd)
return -ENOMEM;
+ /*
+ * We are passing the devres device here so if the user did not pass
+ * another parent, it's this one.
+ */
+ if (!wdd->parent)
+ wdd->parent = dev;
+
ret = watchdog_register_device(wdd);
if (!ret) {
*rcwdd = wdd;
--
2.54.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] watchdog: core: assign parent with devm registration
2026-05-24 2:23 [PATCH] watchdog: core: assign parent with devm registration Rosen Penev
@ 2026-05-24 15:22 ` Guenter Roeck
2026-05-27 16:25 ` Linus Walleij
0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2026-05-24 15:22 UTC (permalink / raw)
To: Rosen Penev, linux-watchdog; +Cc: Wim Van Sebroeck, linusw, open list
On 5/23/26 19:23, Rosen Penev wrote:
> If the user did not pass a parent in the struct watchdog_device
> then use the device used for devres as parent.
>
> This is quite intuitive and can help avoiding having to
> assign parent explicitly in every driver using devres
> to add the watchdog_device.
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
> Linus: hope you don't mind me flat out copying the description from
> https://lore.kernel.org/all/20260427-gpio-mmio-more-v3-1-fe1882351424@kernel.org/
> drivers/watchdog/watchdog_core.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
> index 8300520688d0..726c85debabc 100644
> --- a/drivers/watchdog/watchdog_core.c
> +++ b/drivers/watchdog/watchdog_core.c
> @@ -440,6 +440,13 @@ int devm_watchdog_register_device(struct device *dev,
> if (!rcwdd)
> return -ENOMEM;
>
> + /*
> + * We are passing the devres device here so if the user did not pass
> + * another parent, it's this one.
> + */
> + if (!wdd->parent)
> + wdd->parent = dev;
> +
I understand that you consider it to be garbage, but in my opinion Sashiko has a
point. If the watchdog device data structure is static, wdd->parent will be retained
over multiple remove/reinsert instantiations of the driver, which in turn would result
in subsequent UAF. That means I can not accept your patch.
Guenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] watchdog: core: assign parent with devm registration
2026-05-24 15:22 ` Guenter Roeck
@ 2026-05-27 16:25 ` Linus Walleij
0 siblings, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2026-05-27 16:25 UTC (permalink / raw)
To: Guenter Roeck; +Cc: Rosen Penev, linux-watchdog, Wim Van Sebroeck, open list
On Sun, May 24, 2026 at 5:22 PM Guenter Roeck <linux@roeck-us.net> wrote:
> I understand that you consider it to be garbage, but in my opinion Sashiko has a
> point. If the watchdog device data structure is static, wdd->parent will be retained
> over multiple remove/reinsert instantiations of the driver, which in turn would result
> in subsequent UAF. That means I can not accept your patch.
Hm! I wonder if that is a problem for my patch as well. We do have
GPIO dongles that can be plugged in/out repeatedly....
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-27 16:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-24 2:23 [PATCH] watchdog: core: assign parent with devm registration Rosen Penev
2026-05-24 15:22 ` Guenter Roeck
2026-05-27 16:25 ` Linus Walleij
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®