usb: dwc3: Fix crash on fastboot exit due to incorrect memory free
Subsystems (2)
PATCH 1/1 usb: dwc3: Fix crash on fastboot exit due to incorrect memory free
The dwc3_free_one_event_buffer() function incorrectly called free() on event buffer structures allocated with devm_kzalloc(). This caused heap corruption and a synchronous abort when exiting fastboot mode via "fastboot continue".
Device-managed memory is automatically freed when the device is removed, so manual deallocation causes the heap allocator to access corrupted metadata.
--- drivers/usb/dwc3/core.c | 1 - 1 file changed, 1 deletion(-)
drivers/usb/dwc3/core.c +0 -1
@@ -208,7 +208,6 @@ static void dwc3_free_one_event_buffer(struct dwc3 *dwc, struct dwc3_event_buffer *evt) {dma_free_coherent (evt->buf); -free (evt); }/**
---
base-commit: ae8987f4e690f397f507c4b1efabd68b3ed08db6
change-id: 20260506-usb-8438fa6d437b
Best regards,
Signature · 1 line
Balaji Selvanathan <[email protected]>
Quoted 19 lines · Balaji Selvanathan
The
dwc3_free_one_event_buffer()function incorrectly calledfree()on event buffer structures allocated withdevm_kzalloc(). This caused heap corruption and a synchronous abort when exiting fastboot mode via "fastboot continue".Device-managed memory is automatically freed when the device is removed, so manual deallocation causes the heap allocator to access corrupted metadata.
Signed-off-by Balaji Selvanathan <[email protected]>--- drivers/usb/dwc3/core.c | 1 - 1 file changed, 1 deletion(-)drivers/usb/dwc3/core.c +0
-0
drivers/usb/dwc3/core.c static void dwc3_free_one_event_buffer(struct dwc3 *dwc, · line 213
Quoted 7 lines
drivers/usb/dwc3/core.c +0
-1@@ -208,7 +208,6 @@ static void dwc3_free_one_event_buffer(struct dwc3 *dwc, struct dwc3_event_buffer *evt) {dma_free_coherent (evt->buf); -free (evt); }/**
Does this need:
?
Quoted 29 lines · Marek Vasut
Quoted 19 lines · Balaji Selvanathan
The
dwc3_free_one_event_buffer()function incorrectly calledfree()on event buffer structures allocated withdevm_kzalloc(). This caused heap corruption and a synchronous abort when exiting fastboot mode via "fastboot continue".Device-managed memory is automatically freed when the device is removed, so manual deallocation causes the heap allocator to access corrupted metadata.
Signed-off-by Balaji Selvanathan <[email protected]>---
drivers/usb/dwc3/core.c| 1 -1 file changed, 1 deletion(-)drivers/usb/dwc3/core.c +0
-0drivers/usb/dwc3/core.c static void dwc3_free_one_event_buffer(struct · line 213
Quoted 7 lines
drivers/usb/dwc3/core.c +0
-1@@ -208,7 +208,6 @@ static void dwc3_free_one_event_buffer(struct dwc3 *dwc, struct dwc3_event_buffer *evt) { dma_free_coherent(evt->buf); - free(evt); } /**Does this need:
Quoted 3 lines
Fixes 884b10e86a05 ("usb: dwc3: core: fix memory leaks in event buffer cleanup")?
Hi Marek,
We remove only "free(evt)"; "free(dwc->ev_buffs);" from this patch (884b10e86a05 "usb: dwc3: core: fix memory leaks in event buffer cleanup") is needed.
Regards
Quoted 31 lines · Balaji Selvanathan
Quoted 29 lines · Marek Vasut
Quoted 19 lines · Balaji Selvanathan
The
dwc3_free_one_event_buffer()function incorrectly calledfree()on event buffer structures allocated withdevm_kzalloc(). This caused heap corruption and a synchronous abort when exiting fastboot mode via "fastboot continue".Device-managed memory is automatically freed when the device is removed, so manual deallocation causes the heap allocator to access corrupted metadata.
Signed-off-by Balaji Selvanathan <[email protected]>---
drivers/usb/dwc3/core.c| 1 -1 file changed, 1 deletion(-)drivers/usb/dwc3/core.c +0
-0drivers/usb/dwc3/core.c static void dwc3_free_one_event_buffer(struct · line 213
Quoted 7 lines
drivers/usb/dwc3/core.c +0
-1@@ -208,7 +208,6 @@ static void dwc3_free_one_event_buffer(struct dwc3 *dwc, struct dwc3_event_buffer *evt) { dma_free_coherent(evt->buf); - free(evt); } /**Does this need:
Quoted 7 lines
Quoted 3 lines
Fixes 884b10e86a05 ("usb: dwc3: core: fix memory leaks in event buffer cleanup")?
Hi Marek,
We remove only "free(evt)"; "
free(dwc->ev_buffs);" from this patch (884b10e86a05"usb: dwc3: core: fix memory leaks in event buffer cleanup") is needed.
The Fixes tag is only a reference for posterity, to trace which previous commit this change repairs. The change itself is fine. Thanks !
Quoted 32 lines · Marek Vasut
Quoted 31 lines · Balaji Selvanathan
Quoted 29 lines · Marek Vasut
Quoted 19 lines · Balaji Selvanathan
The
dwc3_free_one_event_buffer()function incorrectly calledfree()on event buffer structures allocated withdevm_kzalloc(). This caused heap corruption and a synchronous abort when exiting fastboot mode via "fastboot continue".Device-managed memory is automatically freed when the device is removed, so manual deallocation causes the heap allocator to access corrupted metadata.
Signed-off-by Balaji Selvanathan <[email protected]>---
drivers/usb/dwc3/core.c| 1 -1 file changed, 1 deletion(-)drivers/usb/dwc3/core.c +0
-0drivers/usb/dwc3/core.c static void dwc3_free_one_event_buffer(struct · line 213
Quoted 7 lines
drivers/usb/dwc3/core.c +0
-1@@ -208,7 +208,6 @@ static void dwc3_free_one_event_buffer(struct dwc3 *dwc, struct dwc3_event_buffer *evt) { dma_free_coherent(evt->buf); - free(evt); } /**Does this need:
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Fixes 884b10e86a05 ("usb: dwc3: core: fix memory leaks in event buffer cleanup")?
Hi Marek,
We remove only "free(evt)"; "
free(dwc->ev_buffs);" from this patch (884b10e86a05"usb: dwc3: core: fix memory leaks in event buffer cleanup") is needed.The Fixes tag is only a reference for posterity, to trace which previous commit this change repairs. The change itself is fine. Thanks !
Hi Marek,
Got it. Thanks for the feedback. Have added fixes tag and respinned: https://lore.kernel.org/u-boot/[email protected]/
Regards,
Balaji