Re: [PATCH] mtd: capture device name setting failure when adding mtd
From: Miquel Raynal
Date: Thu Feb 06 2025 - 11:58:55 EST
Hello Edward,
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index 724f917f91ba..a71cd75858e4 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -741,7 +741,8 @@ int add_mtd_device(struct mtd_info *mtd)
> mtd->dev.type = &mtd_devtype;
> mtd->dev.class = &mtd_class;
> mtd->dev.devt = MTD_DEVT(i);
> - dev_set_name(&mtd->dev, "mtd%d", i);
> + if (error = dev_set_name(&mtd->dev, "mtd%d", i))
Thanks a lot for the analyse and for fixing this. May I ask however to
follow a more common pattern for error checking that is:
error = dev_set_name(...);
if (error)
goto...
This way it is closer to the usual error handling and also aligned with
the rest of the file.
Otherwise LGTM.
Thanks,
Miquèl