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 <maitysancha...@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

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to