diff mbox series

[U-Boot] thor: fix crash after usb initialization failure

Message ID 20190621133929.854-1-m.szyprowski@samsung.com
State Awaiting Upstream
Delegated to: Lukasz Majewski
Headers show
Series [U-Boot] thor: fix crash after usb initialization failure | expand

Commit Message

Marek Szyprowski June 21, 2019, 1:39 p.m. UTC
Registration of USB download gadget might fail for various reasons, so
add a check for g_dnl_register() funtion return value. Without this fix,
thor_init() will try to access the registered gadget structures resulting
in NULL pointer dereference issue.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 cmd/thordown.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/cmd/thordown.c b/cmd/thordown.c
index 19ae6721d19..2e1b2c5bea6 100644
--- a/cmd/thordown.c
+++ b/cmd/thordown.c
@@ -37,7 +37,11 @@  int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		goto exit;
 	}
 
-	g_dnl_register("usb_dnl_thor");
+	ret = g_dnl_register("usb_dnl_thor");
+	if (ret) {
+		error("g_dnl_register failed %d\n", ret);
+		return ret;
+	}
 
 	ret = thor_init();
 	if (ret) {