If device_set_name is called on a device that already has DM_FLAG_NAME_ALLOCED set, the old dynamically-allocated name is leaked. Free it before assigning the new name. See: drivers/net/mdio_gpio.c:mdio_gpio_bind(). There is device_set_name() here, however dm_mdio_post_bind() will also call device_set_name() if "device-name" exists. Signed-off-by: Peng Fan <peng.fan@nxp.com> Reviewed-by: Simon Glass <sjg@chromium.org>