diff options
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r-- | fs/nfsd/nfs4state.c | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 78b9139cdd0f..b9d395856b3a 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -339,21 +339,20 @@ STALE_CLIENTID(clientid_t *clid) | |||
339 | * This type of memory management is somewhat inefficient, but we use it | 339 | * This type of memory management is somewhat inefficient, but we use it |
340 | * anyway since SETCLIENTID is not a common operation. | 340 | * anyway since SETCLIENTID is not a common operation. |
341 | */ | 341 | */ |
342 | static inline struct nfs4_client * | 342 | static struct nfs4_client *alloc_client(struct xdr_netobj name) |
343 | alloc_client(struct xdr_netobj name) | ||
344 | { | 343 | { |
345 | struct nfs4_client *clp; | 344 | struct nfs4_client *clp; |
346 | 345 | ||
347 | if ((clp = kzalloc(sizeof(struct nfs4_client), GFP_KERNEL))!= NULL) { | 346 | clp = kzalloc(sizeof(struct nfs4_client), GFP_KERNEL); |
348 | if ((clp->cl_name.data = kmalloc(name.len, GFP_KERNEL)) != NULL) { | 347 | if (clp == NULL) |
349 | memcpy(clp->cl_name.data, name.data, name.len); | 348 | return NULL; |
350 | clp->cl_name.len = name.len; | 349 | clp->cl_name.data = kmalloc(name.len, GFP_KERNEL); |
351 | } | 350 | if (clp->cl_name.data == NULL) { |
352 | else { | 351 | kfree(clp); |
353 | kfree(clp); | 352 | return NULL; |
354 | clp = NULL; | ||
355 | } | ||
356 | } | 353 | } |
354 | memcpy(clp->cl_name.data, name.data, name.len); | ||
355 | clp->cl_name.len = name.len; | ||
357 | return clp; | 356 | return clp; |
358 | } | 357 | } |
359 | 358 | ||
@@ -421,12 +420,13 @@ expire_client(struct nfs4_client *clp) | |||
421 | put_nfs4_client(clp); | 420 | put_nfs4_client(clp); |
422 | } | 421 | } |
423 | 422 | ||
424 | static struct nfs4_client * | 423 | static struct nfs4_client *create_client(struct xdr_netobj name, char *recdir) |
425 | create_client(struct xdr_netobj name, char *recdir) { | 424 | { |
426 | struct nfs4_client *clp; | 425 | struct nfs4_client *clp; |
427 | 426 | ||
428 | if (!(clp = alloc_client(name))) | 427 | clp = alloc_client(name); |
429 | goto out; | 428 | if (clp == NULL) |
429 | return NULL; | ||
430 | memcpy(clp->cl_recdir, recdir, HEXDIR_LEN); | 430 | memcpy(clp->cl_recdir, recdir, HEXDIR_LEN); |
431 | atomic_set(&clp->cl_count, 1); | 431 | atomic_set(&clp->cl_count, 1); |
432 | atomic_set(&clp->cl_callback.cb_set, 0); | 432 | atomic_set(&clp->cl_callback.cb_set, 0); |
@@ -435,32 +435,30 @@ create_client(struct xdr_netobj name, char *recdir) { | |||
435 | INIT_LIST_HEAD(&clp->cl_openowners); | 435 | INIT_LIST_HEAD(&clp->cl_openowners); |
436 | INIT_LIST_HEAD(&clp->cl_delegations); | 436 | INIT_LIST_HEAD(&clp->cl_delegations); |
437 | INIT_LIST_HEAD(&clp->cl_lru); | 437 | INIT_LIST_HEAD(&clp->cl_lru); |
438 | out: | ||
439 | return clp; | 438 | return clp; |
440 | } | 439 | } |
441 | 440 | ||
442 | static void | 441 | static void copy_verf(struct nfs4_client *target, nfs4_verifier *source) |
443 | copy_verf(struct nfs4_client *target, nfs4_verifier *source) { | 442 | { |
444 | memcpy(target->cl_verifier.data, source->data, sizeof(target->cl_verifier.data)); | 443 | memcpy(target->cl_verifier.data, source->data, |
444 | sizeof(target->cl_verifier.data)); | ||
445 | } | 445 | } |
446 | 446 | ||
447 | static void | 447 | static void copy_clid(struct nfs4_client *target, struct nfs4_client *source) |
448 | copy_clid(struct nfs4_client *target, struct nfs4_client *source) { | 448 | { |
449 | target->cl_clientid.cl_boot = source->cl_clientid.cl_boot; | 449 | target->cl_clientid.cl_boot = source->cl_clientid.cl_boot; |
450 | target->cl_clientid.cl_id = source->cl_clientid.cl_id; | 450 | target->cl_clientid.cl_id = source->cl_clientid.cl_id; |
451 | } | 451 | } |
452 | 452 | ||
453 | static void | 453 | static void copy_cred(struct svc_cred *target, struct svc_cred *source) |
454 | copy_cred(struct svc_cred *target, struct svc_cred *source) { | 454 | { |
455 | |||
456 | target->cr_uid = source->cr_uid; | 455 | target->cr_uid = source->cr_uid; |
457 | target->cr_gid = source->cr_gid; | 456 | target->cr_gid = source->cr_gid; |
458 | target->cr_group_info = source->cr_group_info; | 457 | target->cr_group_info = source->cr_group_info; |
459 | get_group_info(target->cr_group_info); | 458 | get_group_info(target->cr_group_info); |
460 | } | 459 | } |
461 | 460 | ||
462 | static inline int | 461 | static int same_name(const char *n1, const char *n2) |
463 | same_name(const char *n1, const char *n2) | ||
464 | { | 462 | { |
465 | return 0 == memcmp(n1, n2, HEXDIR_LEN); | 463 | return 0 == memcmp(n1, n2, HEXDIR_LEN); |
466 | } | 464 | } |
@@ -502,9 +500,8 @@ static void gen_confirm(struct nfs4_client *clp) | |||
502 | *p++ = i++; | 500 | *p++ = i++; |
503 | } | 501 | } |
504 | 502 | ||
505 | static int | 503 | static int check_name(struct xdr_netobj name) |
506 | check_name(struct xdr_netobj name) { | 504 | { |
507 | |||
508 | if (name.len == 0) | 505 | if (name.len == 0) |
509 | return 0; | 506 | return 0; |
510 | if (name.len > NFS4_OPAQUE_LIMIT) { | 507 | if (name.len > NFS4_OPAQUE_LIMIT) { |