Re: [PATCH] watchdog: take all OF aliases into account when assigning id
| Newsgroups | org.kernel.vger.linux-watchdog |
|---|---|
| Message-ID | <[email protected]> |
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Watchdog devices without a device tree alias will completely fail to register if any watchdog alias in the system has an ID >= MAX_DOGS - 1 (31). -- commit 8dd153efc0fe9ba312373b449e8eef726a399693 Author: Rasmus Villemoes <[email protected]> watchdog: take all OF aliases into account when assigning id This commit ensures that watchdog devices without a device tree alias are allocated an ID greater than the highest numbered alias in the system. This prevents devices without aliases from consuming IDs that are intended for devices with aliases depending on probe order. > diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c > index 8300520688d07..d1f3fa741a4f7 100644 > --- a/drivers/watchdog/watchdog_core.c > +++ b/drivers/watchdog/watchdog_core.c [ ... ] > @@ -265,8 +265,15 @@ static int ___watchdog_register_device(struct watchdog_device *wdd) > GFP_KERNEL); > } > > - if (id < 0) > - id = ida_alloc_max(&watchdog_ida, MAX_DOGS - 1, GFP_KERNEL); > + if (id < 0) { > + ret = of_alias_get_highest_id("watchdog"); > + if (ret >= 0) > + min_id = ret + 1; > + else > + min_id = 0; > + > + id = ida_alloc_range(&watchdog_ida, min_id, MAX_DOGS - 1, GFP_KERNEL); [Severity: High] Does this code prevent unaliased watchdogs from registering if the system defines a high watchdog alias? If a system defines a watchdog alias with an ID of MAX_DOGS - 1 or greater, min_id will evaluate to MAX_DOGS or greater. When passed to ida_alloc_range() with a max limit of MAX_DOGS - 1, the requested minimum will exceed the maximum limit, causing ida_alloc_range() to return -ENOSPC. This would fail the device registration unconditionally for any unaliased watchdog. > + } > > if (id < 0) > return id; -- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1