[U-Boot] [PATCH] cmd: dfu: Add error handling for failed registration

Sanchayan Maity maitysanchayan at gmail.com
Mon Aug 8 13:26:17 CEST 2016


Without this, if g_dnl_register() fails, DFU code continues on
blindly and crashes. This fix makes it simply print an error
message instead.

Signed-off-by: Sanchayan Maity <maitysanchayan at gmail.com>
---
 cmd/dfu.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/cmd/dfu.c b/cmd/dfu.c
index d8aae26..e19d69c 100644
--- a/cmd/dfu.c
+++ b/cmd/dfu.c
@@ -54,7 +54,12 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	int controller_index = simple_strtoul(usb_controller, NULL, 0);
 	board_usb_init(controller_index, USB_INIT_DEVICE);
 	g_dnl_clear_detach();
-	g_dnl_register("usb_dnl_dfu");
+	ret = g_dnl_register("usb_dnl_dfu");
+	if (ret) {
+		error("g_dnl_register failed");
+		return CMD_RET_FAILURE;
+	}
+
 	while (1) {
 		if (g_dnl_detach()) {
 			/*
-- 
2.9.2



More information about the U-Boot mailing list