[PATCH 01/19] commands: devunbind: refuse to unbind devices that were never bound

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Oct 28 02:14:35 PDT 2026


From: Ahmad Fatoum <a.fatoum at barebox.org>

devunbind on a device without a driver crashes in get_device_remove(),
which dereferences dev->driver unchecked. Print a message instead.

-f is not affected, unregistering an unbound device is fine.

Fixes: 4d515afe56eb ("driver: make CONFIG_DEBUG_PROBES more useful for removal")
Assisted-by: Claude:fable-5.1
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
 commands/devunbind.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/commands/devunbind.c b/commands/devunbind.c
index d30193b28527..76dd0b715e6e 100644
--- a/commands/devunbind.c
+++ b/commands/devunbind.c
@@ -52,6 +52,12 @@ static int do_devunbind(int argc, char *argv[])
 			continue;
 		}
 
+		if (!dev->driver) {
+			printf("%s is not bound to a driver\n", argv[i]);
+			ret = COMMAND_ERROR;
+			continue;
+		}
+
 		if (!device_remove(dev)) {
 			printf("no remove callback registered for %s\n", argv[i]);
 			ret = COMMAND_ERROR;
-- 
2.47.3




More information about the barebox mailing list