From: Sanchayan Maity Date: Mon, 8 Aug 2016 16:56:17 +0530 Subject: [U-Boot] [PATCH] cmd: dfu: Add error handling for failed registration Message-ID: <20160808112617.3260-1-maitysanchayan@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 --- 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