mirror of
https://github.com/linux-sunxi/u-boot-sunxi.git
synced 2024-02-12 11:16:03 +08:00
dm: core: Allow device names to be freed automatically
Some devices have a name that is stored in allocated memory. At present there is no mechanism to free this memory when the device is unbound. Add a device flag to track whether a name is allocated and a function to add the flag. Free the memory when the device is unbound. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@ -112,6 +112,8 @@ int device_unbind(struct udevice *dev)
|
||||
|
||||
devres_release_all(dev);
|
||||
|
||||
if (dev->flags & DM_NAME_ALLOCED)
|
||||
free((char *)dev->name);
|
||||
free(dev);
|
||||
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user