]> git.apps.os.sepia.ceph.com Git - ceph-client.git/commitdiff
rbd: use kmemdup()
authorAlex Elder <elder@dreamhost.com>
Thu, 1 Nov 2012 13:39:27 +0000 (08:39 -0500)
committerAlex Elder <elder@inktank.com>
Mon, 19 Nov 2012 23:37:47 +0000 (17:37 -0600)
This replaces two kmalloc()/memcpy() combinations with a single
call to kmemdup().

Signed-off-by: Alex Elder <elder@inktank.com>
drivers/block/rbd.c

index 3378963a3afbe3d12735006e23eaee9e8f8681bc..cf7b4054fb726cc2af5c4ad683c7144388b55b14 100644 (file)
@@ -3153,11 +3153,9 @@ static inline char *dup_token(const char **buf, size_t *lenp)
        size_t len;
 
        len = next_token(buf);
-       dup = kmalloc(len + 1, GFP_KERNEL);
+       dup = kmemdup(*buf, len + 1, GFP_KERNEL);
        if (!dup)
                return NULL;
-
-       memcpy(dup, *buf, len);
        *(dup + len) = '\0';
        *buf += len;
 
@@ -3266,10 +3264,9 @@ static int rbd_add_parse_args(const char *buf,
                ret = -ENAMETOOLONG;
                goto out_err;
        }
-       spec->snap_name = kmalloc(len + 1, GFP_KERNEL);
+       spec->snap_name = kmemdup(buf, len + 1, GFP_KERNEL);
        if (!spec->snap_name)
                goto out_mem;
-       memcpy(spec->snap_name, buf, len);
        *(spec->snap_name + len) = '\0';
 
        /* Initialize all rbd options to the defaults */