[PATCH v1] usb: dwc3: core: fix memory leaks in event buffer cleanup
Marek Vasut
marek.vasut at mailbox.org
Tue Apr 14 08:11:42 CEST 2026
On 4/14/26 7:50 AM, Gurumoorthy Santhakumar wrote:
[...]
> +++ b/drivers/usb/dwc3/core.c
> @@ -206,6 +206,11 @@ static void dwc3_free_one_event_buffer(struct dwc3 *dwc,
> struct dwc3_event_buffer *evt)
> {
> dma_free_coherent(evt->buf);
> +
> + if (evt) {
> + free(evt);
It is valid to call free(NULL) , the if (...) conditional is not needed
here.
> + evt = NULL;
Is this assignment needed ?
> + }
> }
>
> /**
> @@ -252,6 +257,11 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc)
> if (evt)
> dwc3_free_one_event_buffer(dwc, evt);
> }
> +
> + if (dwc->ev_buffs) {
> + free(dwc->ev_buffs);
> + dwc->ev_buffs = NULL;
> + }
Same two comments apply here.
More information about the U-Boot
mailing list