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

rbd: use kstrndup() in rbd_header_from_disk()

Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
Reviewed-by: default avatarJason Dillaman <dillaman@redhat.com>
parent 083a51fb
...@@ -992,15 +992,11 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev, ...@@ -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 */ /* Allocate this now to avoid having to handle failure below */
if (first_time) { if (first_time) {
size_t len; object_prefix = kstrndup(ondisk->object_prefix,
sizeof(ondisk->object_prefix),
len = strnlen(ondisk->object_prefix, GFP_KERNEL);
sizeof (ondisk->object_prefix));
object_prefix = kmalloc(len + 1, GFP_KERNEL);
if (!object_prefix) if (!object_prefix)
return -ENOMEM; return -ENOMEM;
memcpy(object_prefix, ondisk->object_prefix, len);
object_prefix[len] = '\0';
} }
/* Allocate the snapshot context and fill it in */ /* Allocate the snapshot context and fill it in */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment