diff options
author | Kangjie Lu <kjlu@umn.edu> | 2019-03-12 11:20:34 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-05-16 20:41:19 +0300 |
commit | e94f852e2034b6b64f1c4694cc72d3b5274d988d (patch) | |
tree | ebc44586705edebcb20850e11ffb2887b5e72a0e /drivers/nvdimm/namespace_devs.c | |
parent | 5f72e3a021a6392a4988b167e25b859c26bf55df (diff) | |
download | linux-e94f852e2034b6b64f1c4694cc72d3b5274d988d.tar.xz |
libnvdimm/namespace: Fix a potential NULL pointer dereference
[ Upstream commit 55c1fc0af29a6c1b92f217b7eb7581a882e0c07c ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/nvdimm/namespace_devs.c')
-rw-r--r-- | drivers/nvdimm/namespace_devs.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c index 54d79837f7c6..73a444c41cde 100644 --- a/drivers/nvdimm/namespace_devs.c +++ b/drivers/nvdimm/namespace_devs.c @@ -2251,9 +2251,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) |