[PATCH 07/11] boot: imagemap: name the device after its partition

Simon Glass sjg at chromium.org
Tue Oct 20 00:56:32 PDT 2026


Hi Daniel,

On 2026-10-14T08:38:38, Daniel Golle <daniel at makrotopia.org> wrote:
> boot: imagemap: name the device after its partition
>
> imagemap_create() names every device it binds by index "imagemap", so
> two mappings taken on one block device appear as two identically named
> children and the device tree does not say which partition each covers.
> The name also comes straight from the caller, whose string has to outlive
> the device for the driver-model pointer to stay valid.
>
> Derive the name from the partition, by name where one was given and by
> index otherwise, and hand driver model an allocated copy it releases on
> unbind.
>
> Signed-off-by: Daniel Golle <daniel at makrotopia.org>
>
>  boot/imagemap.c | 25 ++++++++++++++++++++++---
>  1 file changed, 22 insertions(+), 3 deletions(-)

> diff --git a/boot/imagemap.c b/boot/imagemap.c
> @@ -441,6 +442,8 @@ int imagemap_create(struct udevice *dev, const char *name,
> +	/*
> +	 * Name the device after the partition it covers, so that two mappings
> +	 * on one block device stay distinct in the device tree.
> +	 */
> +	if (name && *name)
> +		snprintf(buf, sizeof(buf), "%s", name);
> +	else
> +		snprintf(buf, sizeof(buf), "imagemap%d", part);
> +
> +	/* device_bind_driver() keeps the pointer, so hand it one DM can own */
> +	devname = strdup(buf);

The snprintf('%s', name) is a double copy and silently truncates
caller names at 31 chars, which the original pass-through did not.
Please use strdup(name) directly on the name path and keep buf only
for the 'imagemap%d' branch.

Reviewed-by: Simon Glass <sjg at chromium.org>



More information about the openwrt-devel mailing list