Message ID | tencent_0F8E090AA07050A5857F1E9067E6B9DC0C07@qq.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | nvmem: meson-mx-efuse: check the return value of devm_kstrdup() | expand |
Hello, First of all: thank you for this patch! On Sun, Jan 16, 2022 at 6:37 AM <xkernel.wang@foxmail.com> wrote: [...] > @@ -211,6 +211,9 @@ static int meson_mx_efuse_probe(struct platform_device *pdev) > > efuse->config.name = devm_kstrdup(&pdev->dev, drvdata->name, > GFP_KERNEL); > + if (!efuse->config.name) > + return -ENOMEM; Looking at other drivers and also at drivers/nvmem/core.c I believe that the whole devm_kstrdup is unnecessary. Instead I think the code can be simplified as: efuse->config.name = drvdata->name; What do you think? Best regards, Martin
diff --git a/drivers/nvmem/meson-mx-efuse.c b/drivers/nvmem/meson-mx-efuse.c index 07c9f38..38e6a5f 100644 --- a/drivers/nvmem/meson-mx-efuse.c +++ b/drivers/nvmem/meson-mx-efuse.c @@ -211,6 +211,9 @@ static int meson_mx_efuse_probe(struct platform_device *pdev) efuse->config.name = devm_kstrdup(&pdev->dev, drvdata->name, GFP_KERNEL); + if (!efuse->config.name) + return -ENOMEM; + efuse->config.owner = THIS_MODULE; efuse->config.dev = &pdev->dev; efuse->config.priv = efuse;