]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cmd: dfu: Add error handling for failed registration
authorSanchayan Maity <maitysanchayan@gmail.com>
Mon, 8 Aug 2016 11:26:17 +0000 (16:56 +0530)
committerMarek Vasut <marex@denx.de>
Tue, 27 Sep 2016 21:30:22 +0000 (23:30 +0200)
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@gmail.com>
[l.majewski@samsung.com - some manual tweaks needed]

common/dfu.c

index 14b60f1fbbb0039b9855cd20ae6eeaa2c9aa4f4d..4c529f7c36f909a2797b92478653aa2bbde6899d 100644 (file)
@@ -26,7 +26,12 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
 
        board_usb_init(usbctrl_index, USB_INIT_DEVICE);
        g_dnl_clear_detach();
-       g_dnl_register(usb_dnl_gadget);
+       ret = g_dnl_register(usb_dnl_gadget);
+       if (ret) {
+               error("g_dnl_register failed");
+               return CMD_RET_FAILURE;
+       }
+
        while (1) {
                if (g_dnl_detach()) {
                        /*