summaryrefslogtreecommitdiff
path: root/cmd/thordown.c
diff options
context:
space:
mode:
authorMarek Szyprowski <m.szyprowski@samsung.com>2019-06-21 15:39:29 +0200
committerMarek Vasut <marex@denx.de>2019-08-08 11:35:02 +0200
commited3a37a248532367a264380762edf4757f2603f4 (patch)
tree640df07ee1e166da224c44f693a5a69ba12817c1 /cmd/thordown.c
parent160102d112ce6e94b2c924fe2aaafff79808dcba (diff)
downloadu-boot-ed3a37a248532367a264380762edf4757f2603f4.tar.gz
u-boot-ed3a37a248532367a264380762edf4757f2603f4.tar.bz2
u-boot-ed3a37a248532367a264380762edf4757f2603f4.zip
thor: fix crash after usb initialization failure
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>
Diffstat (limited to 'cmd/thordown.c')
-rw-r--r--cmd/thordown.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/cmd/thordown.c b/cmd/thordown.c
index 19ae6721d1..dd0544d475 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) {
+ pr_err("g_dnl_register failed %d\n", ret);
+ return ret;
+ }
ret = thor_init();
if (ret) {