cmd: dfu: Add error handling for failed registration
PATCH 1/1 cmd: dfu: Add error handling for failed registration
Without this, if g_dnl_register() fails, DFU code continues on blindly and crashes. This fix makes it simply print an error message instead.
--- cmd/dfu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
cmd/dfu.c +6 -1
@@ -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 ()) {/*
Signature · 1 line
2.9.2
PATCH 1/1 cmd: dfu: Add error handling for failed registration
Hi Sanchayan,
Quoted 18 lines
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 <[email protected]>--- cmd/dfu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)cmd/dfu.c +0
-0@@ -54,7 +54,12 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, intargc, char * const argv[]) int
controller_index=simple_strtoul(usb_controller, NULL, 0);board_usb_init(controller_index, USB_INIT_DEVICE);g_dnl_clear_detach();
cmd/dfu.c static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 65
Quoted 10 lines
cmd/dfu.c +6
-1-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 ()) {/*
Thanks for spotting, indeed there wasn't return code checking.
I will add this to u-boot-dfu tree.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group