[PATCH] restart: fix restart handler by name selection
Marco Felsch
m.felsch at pengutronix.de
Mon Jun 22 10:21:19 PDT 2026
Commit d20a9a455d8d ("restart: allow selecting restart handler by device
name") introduce a bug, while adding the support to select a restart
handler by device name.
The list_for_each_entry() loop should sort out all restart handler which
don't match the user requested restart handler. Instead all restart
handlers which don't have a device associated are honored as well
because the if condition is always 0 in this case.
Split the if to fix this and add a helper variable to make the code more
readable.
Fixes: d20a9a455d8d ("restart: allow selecting restart handler by device name")
Signed-off-by: Marco Felsch <m.felsch at pengutronix.de>
---
common/restart.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/common/restart.c b/common/restart.c
index 391d7bd3773c..85519912170d 100644
--- a/common/restart.c
+++ b/common/restart.c
@@ -117,8 +117,13 @@ struct restart_handler *restart_handler_get_by_name(const char *name, int flags)
list_for_each_entry(tmp, &restart_handler_list, list) {
if (name) {
- if ((tmp->name && strcmp(name, tmp->name)) &&
- (tmp->dev && strcmp(name, dev_name(tmp->dev))))
+ bool found = false;
+
+ if (tmp->name && !strcmp(name, tmp->name))
+ found = true;
+ if (tmp->dev && !strcmp(name, dev_name(tmp->dev)))
+ found = true;
+ if (!found)
continue;
}
--
2.47.3
More information about the barebox
mailing list