diff mbox series

[v1,3/3] f_fastboot: Avoid use-after-free in the global pointer variable

Message ID 20201203153205.22966-3-andriy.shevchenko@linux.intel.com
State Accepted
Commit 6ffc8e29934391e1569066ca1a1638d261839fa7
Delegated to: Lukasz Majewski
Headers show
Series [v1,1/3] f_rockusb: Use NULL instead of 0 for pointers | expand

Commit Message

Andy Shevchenko Dec. 3, 2020, 3:32 p.m. UTC
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>
---
 drivers/usb/gadget/f_fastboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index d1d087e12b2b..d0d865cf3d08 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;