diff options
author | Arnaldo Carvalho de Melo <acme@mandriva.com> | 2006-11-20 22:21:34 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-12-03 00:30:20 -0500 |
commit | e69062b4f728dca01ec1a9eb4ed55b73a374f164 (patch) | |
tree | 6f8fe0800c07bb53a47bab00e8dfdb4ff9a912e2 /net/sunrpc | |
parent | af997d8c9568d556cd0a362d56de9fb14a6a012a (diff) |
[SUNRPC]: Use k{mem,str}dup where applicable
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r-- | net/sunrpc/auth_gss/auth_gss.c | 3 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/gss_krb5_mech.c | 3 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/gss_spkm3_mech.c | 3 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/svcauth_gss.c | 7 | ||||
-rw-r--r-- | net/sunrpc/clnt.c | 3 |
5 files changed, 6 insertions, 13 deletions
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index b36b9463f5a4..e5a84a482e57 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c | |||
@@ -198,11 +198,10 @@ simple_get_netobj(const void *p, const void *end, struct xdr_netobj *dest) | |||
198 | q = (const void *)((const char *)p + len); | 198 | q = (const void *)((const char *)p + len); |
199 | if (unlikely(q > end || q < p)) | 199 | if (unlikely(q > end || q < p)) |
200 | return ERR_PTR(-EFAULT); | 200 | return ERR_PTR(-EFAULT); |
201 | dest->data = kmalloc(len, GFP_KERNEL); | 201 | dest->data = kmemdup(p, len, GFP_KERNEL); |
202 | if (unlikely(dest->data == NULL)) | 202 | if (unlikely(dest->data == NULL)) |
203 | return ERR_PTR(-ENOMEM); | 203 | return ERR_PTR(-ENOMEM); |
204 | dest->len = len; | 204 | dest->len = len; |
205 | memcpy(dest->data, p, len); | ||
206 | return q; | 205 | return q; |
207 | } | 206 | } |
208 | 207 | ||
diff --git a/net/sunrpc/auth_gss/gss_krb5_mech.c b/net/sunrpc/auth_gss/gss_krb5_mech.c index 325e72e4fd31..754b8cd6439f 100644 --- a/net/sunrpc/auth_gss/gss_krb5_mech.c +++ b/net/sunrpc/auth_gss/gss_krb5_mech.c | |||
@@ -70,10 +70,9 @@ simple_get_netobj(const void *p, const void *end, struct xdr_netobj *res) | |||
70 | q = (const void *)((const char *)p + len); | 70 | q = (const void *)((const char *)p + len); |
71 | if (unlikely(q > end || q < p)) | 71 | if (unlikely(q > end || q < p)) |
72 | return ERR_PTR(-EFAULT); | 72 | return ERR_PTR(-EFAULT); |
73 | res->data = kmalloc(len, GFP_KERNEL); | 73 | res->data = kmemdup(p, len, GFP_KERNEL); |
74 | if (unlikely(res->data == NULL)) | 74 | if (unlikely(res->data == NULL)) |
75 | return ERR_PTR(-ENOMEM); | 75 | return ERR_PTR(-ENOMEM); |
76 | memcpy(res->data, p, len); | ||
77 | res->len = len; | 76 | res->len = len; |
78 | return q; | 77 | return q; |
79 | } | 78 | } |
diff --git a/net/sunrpc/auth_gss/gss_spkm3_mech.c b/net/sunrpc/auth_gss/gss_spkm3_mech.c index bdedf456bc17..d57f60838895 100644 --- a/net/sunrpc/auth_gss/gss_spkm3_mech.c +++ b/net/sunrpc/auth_gss/gss_spkm3_mech.c | |||
@@ -76,10 +76,9 @@ simple_get_netobj(const void *p, const void *end, struct xdr_netobj *res) | |||
76 | q = (const void *)((const char *)p + len); | 76 | q = (const void *)((const char *)p + len); |
77 | if (unlikely(q > end || q < p)) | 77 | if (unlikely(q > end || q < p)) |
78 | return ERR_PTR(-EFAULT); | 78 | return ERR_PTR(-EFAULT); |
79 | res->data = kmalloc(len, GFP_KERNEL); | 79 | res->data = kmemdup(p, len, GFP_KERNEL); |
80 | if (unlikely(res->data == NULL)) | 80 | if (unlikely(res->data == NULL)) |
81 | return ERR_PTR(-ENOMEM); | 81 | return ERR_PTR(-ENOMEM); |
82 | memcpy(res->data, p, len); | ||
83 | return q; | 82 | return q; |
84 | } | 83 | } |
85 | 84 | ||
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c index 1f0f079ffa65..700353b330fd 100644 --- a/net/sunrpc/auth_gss/svcauth_gss.c +++ b/net/sunrpc/auth_gss/svcauth_gss.c | |||
@@ -113,9 +113,7 @@ static int rsi_match(struct cache_head *a, struct cache_head *b) | |||
113 | static int dup_to_netobj(struct xdr_netobj *dst, char *src, int len) | 113 | static int dup_to_netobj(struct xdr_netobj *dst, char *src, int len) |
114 | { | 114 | { |
115 | dst->len = len; | 115 | dst->len = len; |
116 | dst->data = (len ? kmalloc(len, GFP_KERNEL) : NULL); | 116 | dst->data = (len ? kmemdup(src, len, GFP_KERNEL) : NULL); |
117 | if (dst->data) | ||
118 | memcpy(dst->data, src, len); | ||
119 | if (len && !dst->data) | 117 | if (len && !dst->data) |
120 | return -ENOMEM; | 118 | return -ENOMEM; |
121 | return 0; | 119 | return 0; |
@@ -756,10 +754,9 @@ svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name) | |||
756 | if (!new) | 754 | if (!new) |
757 | goto out; | 755 | goto out; |
758 | kref_init(&new->h.ref); | 756 | kref_init(&new->h.ref); |
759 | new->h.name = kmalloc(strlen(name) + 1, GFP_KERNEL); | 757 | new->h.name = kstrdup(name, GFP_KERNEL); |
760 | if (!new->h.name) | 758 | if (!new->h.name) |
761 | goto out_free_dom; | 759 | goto out_free_dom; |
762 | strcpy(new->h.name, name); | ||
763 | new->h.flavour = &svcauthops_gss; | 760 | new->h.flavour = &svcauthops_gss; |
764 | new->pseudoflavor = pseudoflavor; | 761 | new->pseudoflavor = pseudoflavor; |
765 | 762 | ||
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 78696f2dc7d6..dfeea4fea95a 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
@@ -253,10 +253,9 @@ rpc_clone_client(struct rpc_clnt *clnt) | |||
253 | { | 253 | { |
254 | struct rpc_clnt *new; | 254 | struct rpc_clnt *new; |
255 | 255 | ||
256 | new = kmalloc(sizeof(*new), GFP_KERNEL); | 256 | new = kmemdup(clnt, sizeof(*new), GFP_KERNEL); |
257 | if (!new) | 257 | if (!new) |
258 | goto out_no_clnt; | 258 | goto out_no_clnt; |
259 | memcpy(new, clnt, sizeof(*new)); | ||
260 | atomic_set(&new->cl_count, 1); | 259 | atomic_set(&new->cl_count, 1); |
261 | atomic_set(&new->cl_users, 0); | 260 | atomic_set(&new->cl_users, 0); |
262 | new->cl_parent = clnt; | 261 | new->cl_parent = clnt; |