Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e94f852e authored by Kangjie Lu's avatar Kangjie Lu Committed by Greg Kroah-Hartman
Browse files

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: default avatarKangjie Lu <kjlu@umn.edu>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 5f72e3a0
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -2251,9 +2251,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)