summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2020-12-03 18:32:05 +0300
committerMarek Vasut <marex@denx.de>2021-01-31 16:08:56 +0300
commit6ffc8e29934391e1569066ca1a1638d261839fa7 (patch)
treeb5b314dad5e2917c6fe5ebe2fd9ea3c998d3c3d7
parentff52577c1b5188a5f25bd7d7d41730bb5de4b688 (diff)
downloadu-boot-6ffc8e29934391e1569066ca1a1638d261839fa7.tar.xz
f_fastboot: Avoid use-after-free in the global pointer variable
In case of usb_add_function() failure the error path has an issue, i.e the global pointer variable is assigned to garbage Fix the above mentioned issue by assigning pointer to NULL. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-rw-r--r--drivers/usb/gadget/f_fastboot.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index d1d087e12b..d0d865cf3d 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -315,7 +315,7 @@ static int fastboot_add(struct usb_configuration *c)
status = usb_add_function(c, &f_fb->usb_function);
if (status) {
free(f_fb);
- fastboot_func = f_fb;
+ fastboot_func = NULL;
}
return status;