[Concept,13/17] mtd: spi: Fix device name leak in sandbox SPI flash emulator

Message ID 20260316183050.3855921-14-sjg@u-boot.org
State New
Headers
Series Add automatic memory-leak detection to U-Boot tests |

Commit Message

Simon Glass March 16, 2026, 6:30 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

sandbox_sf_bind_emul() allocates a device name with strdup() but does
not mark it with DM_FLAG_NAME_ALLOCED, so device_unbind() never frees
it.

Add the missing device_set_name_alloced() call.

Fixes: b6c2956defb4 ("dm: sf: sandbox: Convert SPI flash driver to driver model")
Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/mtd/spi/sandbox.c | 1 +
 1 file changed, 1 insertion(+)
  

Patch

diff --git a/drivers/mtd/spi/sandbox.c b/drivers/mtd/spi/sandbox.c
index 0b56312bb85..573ce463294 100644
--- a/drivers/mtd/spi/sandbox.c
+++ b/drivers/mtd/spi/sandbox.c
@@ -553,6 +553,7 @@  int sandbox_sf_bind_emul(struct sandbox_state *state, int busnum, int cs,
 		       spec, ret);
 		return ret;
 	}
+	device_set_name_alloced(emul);
 	state->spi[busnum][cs].emul = emul;
 
 	return 0;