mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-27 23:20:26 +09:00
f_rockusb: Avoid use-after-free in the global pointer variable
In case of usb_add_function() failure the error path has two issues: - the potentially allocated structure isn't getting freed - the global pointer variable is assigned to garbage Fix the above mentioned issues by freeing memory and assigning NULL. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
This commit is contained in:
parent
0234609d96
commit
ff52577c1b
@ -309,8 +309,9 @@ static int rockusb_add(struct usb_configuration *c)
|
|||||||
|
|
||||||
status = usb_add_function(c, &f_rkusb->usb_function);
|
status = usb_add_function(c, &f_rkusb->usb_function);
|
||||||
if (status) {
|
if (status) {
|
||||||
|
free(f_rkusb->buf_head);
|
||||||
free(f_rkusb);
|
free(f_rkusb);
|
||||||
rockusb_func = f_rkusb;
|
rockusb_func = NULL;
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user