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

Commit 848d796c authored by Ilya Dryomov's avatar Ilya Dryomov
Browse files

rbd: use kstrndup() in rbd_header_from_disk()

parent 083a51fb
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -992,15 +992,11 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
	/* Allocate this now to avoid having to handle failure below */

	if (first_time) {
		size_t len;

		len = strnlen(ondisk->object_prefix,
				sizeof (ondisk->object_prefix));
		object_prefix = kmalloc(len + 1, GFP_KERNEL);
		object_prefix = kstrndup(ondisk->object_prefix,
					 sizeof(ondisk->object_prefix),
					 GFP_KERNEL);
		if (!object_prefix)
			return -ENOMEM;
		memcpy(object_prefix, ondisk->object_prefix, len);
		object_prefix[len] = '\0';
	}

	/* Allocate the snapshot context and fill it in */