diff options
author | Thomas Meyer <thomas@m3y3r.de> | 2011-11-17 17:43:40 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2011-11-25 18:44:22 -0500 |
commit | 67114fe6103183190fb0a24f58e5695a80beb2ec (patch) | |
tree | 65696c5d33a37acf7af71a5fd6bab0f9c0c155fe /fs/nfsd | |
parent | 009673b439cf74d70a486fca0177e274febd81a7 (diff) |
nfsd4: 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: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfs4state.c | 3 | ||||
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 3 |
2 files changed, 2 insertions, 4 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index a84978c13bb8..6ab677913f9c 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -986,12 +986,11 @@ static struct nfs4_client *alloc_client(struct xdr_netobj name) | |||
986 | clp = kzalloc(sizeof(struct nfs4_client), GFP_KERNEL); | 986 | clp = kzalloc(sizeof(struct nfs4_client), GFP_KERNEL); |
987 | if (clp == NULL) | 987 | if (clp == NULL) |
988 | return NULL; | 988 | return NULL; |
989 | clp->cl_name.data = kmalloc(name.len, GFP_KERNEL); | 989 | clp->cl_name.data = kmemdup(name.data, name.len, GFP_KERNEL); |
990 | if (clp->cl_name.data == NULL) { | 990 | if (clp->cl_name.data == NULL) { |
991 | kfree(clp); | 991 | kfree(clp); |
992 | return NULL; | 992 | return NULL; |
993 | } | 993 | } |
994 | memcpy(clp->cl_name.data, name.data, name.len); | ||
995 | clp->cl_name.len = name.len; | 994 | clp->cl_name.len = name.len; |
996 | return clp; | 995 | return clp; |
997 | } | 996 | } |
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index b6fa792d6b85..0ec5a1b9700e 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -215,10 +215,9 @@ defer_free(struct nfsd4_compoundargs *argp, | |||
215 | static char *savemem(struct nfsd4_compoundargs *argp, __be32 *p, int nbytes) | 215 | static char *savemem(struct nfsd4_compoundargs *argp, __be32 *p, int nbytes) |
216 | { | 216 | { |
217 | if (p == argp->tmp) { | 217 | if (p == argp->tmp) { |
218 | p = kmalloc(nbytes, GFP_KERNEL); | 218 | p = kmemdup(argp->tmp, nbytes, GFP_KERNEL); |
219 | if (!p) | 219 | if (!p) |
220 | return NULL; | 220 | return NULL; |
221 | memcpy(p, argp->tmp, nbytes); | ||
222 | } else { | 221 | } else { |
223 | BUG_ON(p != argp->tmpp); | 222 | BUG_ON(p != argp->tmpp); |
224 | argp->tmpp = NULL; | 223 | argp->tmpp = NULL; |