Skip to content
Commit 32f4f8d9 authored by Steven Slupsky's avatar Steven Slupsky Committed by Mahesh Mahadevan
Browse files

drivers: usb: usb_dc_sam0: fix memory leak



The usb_dc_sam0 driver is leaking memory when the usb device is detached
using usb_disable().

When a device is detached, the driver does not reliably deallocate the
descriptor bank memory. Therefore, upon the next attach and configure,
another block of memory is allocated. After several connect /
disconnect sequences, the usb interface becomes unresponsive.

This commit adds a static function to release all memory allocated
to the ep descriptors when usb_dc_detach() is called.  Since detach is
called from usb_disable(), this releases the memory when the
interface is disabled.

Avoid calling k_free() if buffer pointer is already
set to NULL.

Fixes #49177

Signed-off-by: default avatarSteven Slupsky <sslupsky@gmail.com>
parent 7c231e3e
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment