[PATCH] nvmem: meson-mx-efuse: check the return value of devm_kstrdup()

From: xkernel . wang
Date: Sun Jan 16 2022 - 00:44:59 EST


From: Xiaoke Wang <xkernel.wang@xxxxxxxxxxx>

devm_kstrdup() returns pointer to allocated string on success,
NULL on failure. So it is better to check the return value of it.

Signed-off-by: Xiaoke Wang <xkernel.wang@xxxxxxxxxxx>
---
drivers/nvmem/meson-mx-efuse.c | 3 +++
1 file changed, 3 insertions(+)

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;
--