Skip to content

Commit 55c1fc0

Browse files
kengiterdjbw
authored andcommitted
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 <[email protected]> Signed-off-by: Dan Williams <[email protected]>
1 parent 351f339 commit 55c1fc0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/nvdimm/namespace_devs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2249,9 +2249,12 @@ static struct device *create_namespace_blk(struct nd_region *nd_region,
22492249
if (!nsblk->uuid)
22502250
goto blk_err;
22512251
memcpy(name, nd_label->name, NSLABEL_NAME_LEN);
2252-
if (name[0])
2252+
if (name[0]) {
22532253
nsblk->alt_name = kmemdup(name, NSLABEL_NAME_LEN,
22542254
GFP_KERNEL);
2255+
if (!nsblk->alt_name)
2256+
goto blk_err;
2257+
}
22552258
res = nsblk_add_resource(nd_region, ndd, nsblk,
22562259
__le64_to_cpu(nd_label->dpa));
22572260
if (!res)

0 commit comments

Comments
 (0)