[SUNRPC]: Use k{mem,str}dup where applicable
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
This commit is contained in:
parent
af997d8c95
commit
e69062b4f7
@ -198,11 +198,10 @@ simple_get_netobj(const void *p, const void *end, struct xdr_netobj *dest)
|
|||||||
q = (const void *)((const char *)p + len);
|
q = (const void *)((const char *)p + len);
|
||||||
if (unlikely(q > end || q < p))
|
if (unlikely(q > end || q < p))
|
||||||
return ERR_PTR(-EFAULT);
|
return ERR_PTR(-EFAULT);
|
||||||
dest->data = kmalloc(len, GFP_KERNEL);
|
dest->data = kmemdup(p, len, GFP_KERNEL);
|
||||||
if (unlikely(dest->data == NULL))
|
if (unlikely(dest->data == NULL))
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
dest->len = len;
|
dest->len = len;
|
||||||
memcpy(dest->data, p, len);
|
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,10 +70,9 @@ simple_get_netobj(const void *p, const void *end, struct xdr_netobj *res)
|
|||||||
q = (const void *)((const char *)p + len);
|
q = (const void *)((const char *)p + len);
|
||||||
if (unlikely(q > end || q < p))
|
if (unlikely(q > end || q < p))
|
||||||
return ERR_PTR(-EFAULT);
|
return ERR_PTR(-EFAULT);
|
||||||
res->data = kmalloc(len, GFP_KERNEL);
|
res->data = kmemdup(p, len, GFP_KERNEL);
|
||||||
if (unlikely(res->data == NULL))
|
if (unlikely(res->data == NULL))
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
memcpy(res->data, p, len);
|
|
||||||
res->len = len;
|
res->len = len;
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
@ -76,10 +76,9 @@ simple_get_netobj(const void *p, const void *end, struct xdr_netobj *res)
|
|||||||
q = (const void *)((const char *)p + len);
|
q = (const void *)((const char *)p + len);
|
||||||
if (unlikely(q > end || q < p))
|
if (unlikely(q > end || q < p))
|
||||||
return ERR_PTR(-EFAULT);
|
return ERR_PTR(-EFAULT);
|
||||||
res->data = kmalloc(len, GFP_KERNEL);
|
res->data = kmemdup(p, len, GFP_KERNEL);
|
||||||
if (unlikely(res->data == NULL))
|
if (unlikely(res->data == NULL))
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
memcpy(res->data, p, len);
|
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,9 +113,7 @@ static int rsi_match(struct cache_head *a, struct cache_head *b)
|
|||||||
static int dup_to_netobj(struct xdr_netobj *dst, char *src, int len)
|
static int dup_to_netobj(struct xdr_netobj *dst, char *src, int len)
|
||||||
{
|
{
|
||||||
dst->len = len;
|
dst->len = len;
|
||||||
dst->data = (len ? kmalloc(len, GFP_KERNEL) : NULL);
|
dst->data = (len ? kmemdup(src, len, GFP_KERNEL) : NULL);
|
||||||
if (dst->data)
|
|
||||||
memcpy(dst->data, src, len);
|
|
||||||
if (len && !dst->data)
|
if (len && !dst->data)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
return 0;
|
return 0;
|
||||||
@ -756,10 +754,9 @@ svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name)
|
|||||||
if (!new)
|
if (!new)
|
||||||
goto out;
|
goto out;
|
||||||
kref_init(&new->h.ref);
|
kref_init(&new->h.ref);
|
||||||
new->h.name = kmalloc(strlen(name) + 1, GFP_KERNEL);
|
new->h.name = kstrdup(name, GFP_KERNEL);
|
||||||
if (!new->h.name)
|
if (!new->h.name)
|
||||||
goto out_free_dom;
|
goto out_free_dom;
|
||||||
strcpy(new->h.name, name);
|
|
||||||
new->h.flavour = &svcauthops_gss;
|
new->h.flavour = &svcauthops_gss;
|
||||||
new->pseudoflavor = pseudoflavor;
|
new->pseudoflavor = pseudoflavor;
|
||||||
|
|
||||||
|
@ -253,10 +253,9 @@ rpc_clone_client(struct rpc_clnt *clnt)
|
|||||||
{
|
{
|
||||||
struct rpc_clnt *new;
|
struct rpc_clnt *new;
|
||||||
|
|
||||||
new = kmalloc(sizeof(*new), GFP_KERNEL);
|
new = kmemdup(clnt, sizeof(*new), GFP_KERNEL);
|
||||||
if (!new)
|
if (!new)
|
||||||
goto out_no_clnt;
|
goto out_no_clnt;
|
||||||
memcpy(new, clnt, sizeof(*new));
|
|
||||||
atomic_set(&new->cl_count, 1);
|
atomic_set(&new->cl_count, 1);
|
||||||
atomic_set(&new->cl_users, 0);
|
atomic_set(&new->cl_users, 0);
|
||||||
new->cl_parent = clnt;
|
new->cl_parent = clnt;
|
||||||
|
Loading…
Reference in New Issue
Block a user