Commit 67114fe6 authored by Thomas Meyer's avatar Thomas Meyer Committed by J. Bruce Fields

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: default avatarThomas Meyer <thomas@m3y3r.de>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 009673b4
...@@ -986,12 +986,11 @@ static struct nfs4_client *alloc_client(struct xdr_netobj name) ...@@ -986,12 +986,11 @@ static struct nfs4_client *alloc_client(struct xdr_netobj name)
clp = kzalloc(sizeof(struct nfs4_client), GFP_KERNEL); clp = kzalloc(sizeof(struct nfs4_client), GFP_KERNEL);
if (clp == NULL) if (clp == NULL)
return NULL; return NULL;
clp->cl_name.data = kmalloc(name.len, GFP_KERNEL); clp->cl_name.data = kmemdup(name.data, name.len, GFP_KERNEL);
if (clp->cl_name.data == NULL) { if (clp->cl_name.data == NULL) {
kfree(clp); kfree(clp);
return NULL; return NULL;
} }
memcpy(clp->cl_name.data, name.data, name.len);
clp->cl_name.len = name.len; clp->cl_name.len = name.len;
return clp; return clp;
} }
......
...@@ -215,10 +215,9 @@ defer_free(struct nfsd4_compoundargs *argp, ...@@ -215,10 +215,9 @@ defer_free(struct nfsd4_compoundargs *argp,
static char *savemem(struct nfsd4_compoundargs *argp, __be32 *p, int nbytes) static char *savemem(struct nfsd4_compoundargs *argp, __be32 *p, int nbytes)
{ {
if (p == argp->tmp) { if (p == argp->tmp) {
p = kmalloc(nbytes, GFP_KERNEL); p = kmemdup(argp->tmp, nbytes, GFP_KERNEL);
if (!p) if (!p)
return NULL; return NULL;
memcpy(p, argp->tmp, nbytes);
} else { } else {
BUG_ON(p != argp->tmpp); BUG_ON(p != argp->tmpp);
argp->tmpp = NULL; argp->tmpp = NULL;
......
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