summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKangjie Lu <kjlu@umn.edu>2019-03-12 03:20:34 -0500
committerDan Williams <dan.j.williams@intel.com>2019-03-22 16:19:54 -0700
commit55c1fc0af29a6c1b92f217b7eb7581a882e0c07c (patch)
treee63fa83ae1ccc403b1330ecc0269c4930e190a87
parent351f339faa308c1c1461314a18c832239a841ca0 (diff)
libnvdimm/namespace: Fix a potential NULL pointer dereference
In case kmemdup fails, the fix goes to blk_err to avoid NULL pointer dereference. Signed-off-by: Kangjie Lu <kjlu@umn.edu> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--drivers/nvdimm/namespace_devs.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 7849bf1812c4..f293556cbbf6 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -2249,9 +2249,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)