Commit 55c1fc0a authored by Kangjie Lu's avatar Kangjie Lu Committed by Dan Williams
Browse files

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: default avatarKangjie Lu <>
Signed-off-by: default avatarDan Williams <>
parent 351f339f
......@@ -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,
if (!nsblk->alt_name)
goto blk_err;
res = nsblk_add_resource(nd_region, ndd, nsblk,
if (!res)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment