mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-02 09:46:37 +03:00
usb: gadget: f_acm: Fix memory leak in acm_add
If udc_device_get_by_index fails, the f_acm struct was not released. Free it before returning the error. Signed-off-by: Francois Berder <fberder@outlook.fr> Reviewed-by: Marek Vasut <marek.vasut+usb@mailbox.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org> Link: https://patch.msgid.link/BESP194MB2805271AD5DBE47B322F8DC3DA3A2@BESP194MB2805.EURP194.PROD.OUTLOOK.COM Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
This commit is contained in:
committed by
Mattijs Korpershoek
parent
36d4c65358
commit
c8f6823442
@@ -548,13 +548,11 @@ static int acm_add(struct usb_configuration *c)
|
||||
|
||||
status = udc_device_get_by_index(0, &f_acm->udc);
|
||||
if (status)
|
||||
return status;
|
||||
goto err;
|
||||
|
||||
status = usb_add_function(c, &f_acm->usb_function);
|
||||
if (status) {
|
||||
free(f_acm);
|
||||
return status;
|
||||
}
|
||||
if (status)
|
||||
goto err;
|
||||
|
||||
buf_init(&f_acm->rx_buf, 2048);
|
||||
buf_init(&f_acm->tx_buf, 2048);
|
||||
@@ -562,6 +560,10 @@ static int acm_add(struct usb_configuration *c)
|
||||
if (!default_acm_function)
|
||||
default_acm_function = f_acm;
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
free(f_acm);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user