From: Andy Shevchenko Date: Thu, 3 Dec 2020 15:32:05 +0000 (+0200) Subject: f_fastboot: Avoid use-after-free in the global pointer variable X-Git-Url: http://git.dujemihanovic.xyz/img/static/gitweb.css?a=commitdiff_plain;h=6ffc8e29934391e1569066ca1a1638d261839fa7;p=u-boot.git 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 --- 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;