* [PATCH] nvdimm: namespace_devs: fix a potential NULL pointer dereference
@ 2019-03-12 8:20 Kangjie Lu
0 siblings, 0 replies; only message in thread
From: Kangjie Lu @ 2019-03-12 8:20 UTC (permalink / raw)
To: kjlu-OJFnDUYgAso
Cc: linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw, pakki001-OJFnDUYgAso,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Ross Zwisler
In case kmemdup fails, the fix goes to blk_err to avoid NULL
pointer dereference
Signed-off-by: Kangjie Lu <kjlu-OJFnDUYgAso@public.gmane.org>
---
drivers/nvdimm/namespace_devs.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 4b077555ac70..6f65261e151f 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -2245,9 +2245,12 @@ static struct device *create_namespace_blk(struct nd_region *nd_region,
if (!nsblk->uuid)
goto blk_err;
memcpy(name, nd_label->name, NSLABEL_NAME_LEN);
- if (name[0])
+ if (name[0]) {
nsblk->alt_name = kmemdup(name, NSLABEL_NAME_LEN,
GFP_KERNEL);
+ if (!nsblk->alt_name)
+ goto blk_err;
+ }
res = nsblk_add_resource(nd_region, ndd, nsblk,
__le64_to_cpu(nd_label->dpa));
if (!res)
--
2.17.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-03-12 8:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-12 8:20 [PATCH] nvdimm: namespace_devs: fix a potential NULL pointer dereference Kangjie Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).