ceph: Use kmemdup rather than duplicating its implementation
authorThomas Meyer <thomas@m3y3r.de>
Thu, 10 Nov 2011 18:45:21 +0000 (19:45 +0100)
committerSage Weil <sage@newdream.net>
Tue, 10 Jan 2012 16:56:54 +0000 (08:56 -0800)
Use kmemdup rather than duplicating its implementation

The semantic patch that makes this change is available
in scripts/coccinelle/api/memdup.cocci.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Signed-off-by: Sage Weil <sage@newdream.net>
net/ceph/crypto.c

index 85f3bc0..b780cb7 100644 (file)
@@ -15,10 +15,9 @@ int ceph_crypto_key_clone(struct ceph_crypto_key *dst,
                          const struct ceph_crypto_key *src)
 {
        memcpy(dst, src, sizeof(struct ceph_crypto_key));
-       dst->key = kmalloc(src->len, GFP_NOFS);
+       dst->key = kmemdup(src->key, src->len, GFP_NOFS);
        if (!dst->key)
                return -ENOMEM;
-       memcpy(dst->key, src->key, src->len);
        return 0;
 }