From: Xiaoke Wang <xkernel.wang@foxmail.com>
To: oohall@gmail.com
Cc: nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org,
Xiaoke Wang <xkernel.wang@foxmail.com>
Subject: [PATCH] libnvdimm/of_pmem: check the return value of kstrdup()
Date: Mon, 13 Dec 2021 11:13:05 +0800 [thread overview]
Message-ID: <tencent_C1508086CF28C5FD4B834C3393E53271E80A@qq.com> (raw)
kstrdup() returns NULL when some internal memory erros happen, it is
better to check the return value of it so to catch the memory error in
time.
Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
---
drivers/nvdimm/of_pmem.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c
index 10dbdcd..33978d2 100644
--- a/drivers/nvdimm/of_pmem.c
+++ b/drivers/nvdimm/of_pmem.c
@@ -31,6 +31,10 @@ static int of_pmem_region_probe(struct platform_device *pdev)
return -ENOMEM;
priv->bus_desc.provider_name = kstrdup(pdev->name, GFP_KERNEL);
+ if (!priv->bus_desc.provider_name) {
+ kfree(priv);
+ return -ENOMEM;
+ }
priv->bus_desc.module = THIS_MODULE;
priv->bus_desc.of_node = np;
--
reply other threads:[~2021-12-13 3:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_C1508086CF28C5FD4B834C3393E53271E80A@qq.com \
--to=xkernel.wang@foxmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=oohall@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®