mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-08 15:48:23 +00:00
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>
This commit is contained in:
parent
351f339faa
commit
55c1fc0af2
1 changed files with 4 additions and 1 deletions
|
@ -2249,9 +2249,12 @@ static struct device *create_namespace_blk(struct nd_region *nd_region,
|
||||||
if (!nsblk->uuid)
|
if (!nsblk->uuid)
|
||||||
goto blk_err;
|
goto blk_err;
|
||||||
memcpy(name, nd_label->name, NSLABEL_NAME_LEN);
|
memcpy(name, nd_label->name, NSLABEL_NAME_LEN);
|
||||||
if (name[0])
|
if (name[0]) {
|
||||||
nsblk->alt_name = kmemdup(name, NSLABEL_NAME_LEN,
|
nsblk->alt_name = kmemdup(name, NSLABEL_NAME_LEN,
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
|
if (!nsblk->alt_name)
|
||||||
|
goto blk_err;
|
||||||
|
}
|
||||||
res = nsblk_add_resource(nd_region, ndd, nsblk,
|
res = nsblk_add_resource(nd_region, ndd, nsblk,
|
||||||
__le64_to_cpu(nd_label->dpa));
|
__le64_to_cpu(nd_label->dpa));
|
||||||
if (!res)
|
if (!res)
|
||||||
|
|
Loading…
Add table
Reference in a new issue