[PATCH] mtd: rawnand: fsl_ifc: use devm_kasprintf for mtd name
Rosen Penev
rosenp at gmail.com
Wed Sep 9 16:03:09 PDT 2026
On Wed, Sep 9, 2026 at 3:38 PM Rosen Penev <rosenp at gmail.com> wrote:
>
> Replace the manual kasprintf() in probe with devm_kasprintf() so the
> name is freed automatically on driver removal, and drop the now
> unnecessary kfree() in fsl_ifc_chip_remove() and its leftover mtd
> local.
>
> Assisted-by: opencode:big-pickle
> Signed-off-by: Rosen Penev <rosenp at gmail.com>
> ---
> drivers/mtd/nand/raw/fsl_ifc_nand.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/fsl_ifc_nand.c b/drivers/mtd/nand/raw/fsl_ifc_nand.c
> index 469b233db73e..cc75b6a67e07 100644
> --- a/drivers/mtd/nand/raw/fsl_ifc_nand.c
> +++ b/drivers/mtd/nand/raw/fsl_ifc_nand.c
> @@ -963,10 +963,6 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv)
>
> static int fsl_ifc_chip_remove(struct fsl_ifc_mtd *priv)
> {
> - struct mtd_info *mtd = nand_to_mtd(&priv->chip);
> -
> - kfree(mtd->name);
> -
> ifc_nand_ctrl->chips[priv->bank] = NULL;
>
> return 0;
> @@ -1061,7 +1057,7 @@ static int fsl_ifc_nand_probe(struct platform_device *dev)
> &ifc->ifc_nand.nand_evter_intr_en);
>
> mtd = nand_to_mtd(&priv->chip);
> - mtd->name = kasprintf(GFP_KERNEL, "%llx.flash", (u64)res->start);
> + mtd->name = devm_kasprintf(priv->dev, GFP_KERNEL, "%llx.flash", (u64)res->start);
Having &mtd->dev as the first argument would be interesting but nobody
does this.
> if (!mtd->name) {
> ret = -ENOMEM;
> goto err;
> --
> 2.55.0
>
More information about the linux-mtd
mailing list