[PATCH 02/11] cmd: ubi: report a failed UBI block device bind
Simon Glass
sjg at chromium.org
Thu Oct 1 08:59:45 PDT 2026
Hi Daniel,
On 2026-09-29T00:04:16, Daniel Golle <daniel at makrotopia.org> wrote:
> cmd: ubi: report a failed UBI block device bind
>
> ubi_blk_bind_once() drops the ubi_bind() return value, so when the bind
> fails the attach still reports success and the caller finds no ubi_blk
> device with nothing to explain it.
Not quite. The only failure path in ubi_bind() is
blk_create_devicef(), which already calls pr_err("Cannot create block
device") at the default LOGLEVEL, so the user does get a message
today. What it lacks is the errno and any mention of UBI. Please can
you reword this to match?
>
> Report the errno. The attach itself is not failed: UBI is available
> either way and the block device is an optional view of it, so a UBIFS
> user must not lose the partition because the block layer could not be
> set up.
>
> Fixes: dec405d1653a ("cmd: ubi: create a ubi_blk device when attaching UBI")
> Signed-off-by: Daniel Golle <daniel at makrotopia.org>
>
> cmd/ubi.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
> diff --git a/cmd/ubi.c b/cmd/ubi.c
> @@ -690,7 +692,11 @@ static void ubi_blk_bind_once(void)
> + ret = ubi_bind(parent);
> + if (ret)
> + printf("Cannot create UBI block device: %d\n", ret);
A failure now prints two messages, and since the pr_err() in
ubi_bind() has no trailing newline they run together:
Cannot create block deviceCannot create UBI block device: -12
I suggest dropping the pr_err() from ubi_bind() so the caller does the
reporting, as your patch 1 does in mtd_blk_bind_master(). Patch 3
already changes ubi_bind(), so it could go there or here.
Alternatively, keep the message in ubi_bind(), add the errno and a
newline, and leave this caller silent. What do you think?
I agree with not failing the attach.
Regards,
Simon
More information about the openwrt-devel
mailing list