From: Marek Szyprowski Date: Fri, 21 Jun 2019 13:39:29 +0000 (+0200) Subject: thor: fix crash after usb initialization failure X-Git-Tag: v2019.10-rc2~8^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ed3a37a248532367a264380762edf4757f2603f4;p=platform%2Fkernel%2Fu-boot.git 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 --- diff --git a/cmd/thordown.c b/cmd/thordown.c index 19ae672..dd0544d 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) {