[Concept,10/33] blk: Mark partition name as alloced

Message ID 20260416023021.626949-11-sjg@u-boot.org
State New
Headers
Series Fix memory leaks and test pollution in sandbox tests |

Commit Message

Simon Glass April 16, 2026, 2:29 a.m. UTC
  From: Simon Glass <sjg@chromium.org>

part_create_block_devices() allocates a name for the block-partition
driver, but device_bind_driver() does not set DM_FLAG_NAME_ALLOCED, so
the name is not released when the partition device is unbound. Every
scanned partition thus leaks its name.

Call device_set_name_alloced() so the core frees it on unbind.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/block/blk-uclass.c | 1 +
 1 file changed, 1 insertion(+)
  

Patch

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 9c9169d6ac8..611859435f2 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -808,6 +808,7 @@  static int part_create_block_devices(struct udevice *blk_dev)
 					 strdup(devname), &dev);
 		if (ret)
 			return ret;
+		device_set_name_alloced(dev);
 
 		part_data = dev_get_uclass_plat(dev);
 		part_data->partnum = part;