aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4idmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfsd/nfs4idmap.c')
-rw-r--r--fs/nfsd/nfs4idmap.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
index 4c0c683ce07a..996bd88b75ba 100644
--- a/fs/nfsd/nfs4idmap.c
+++ b/fs/nfsd/nfs4idmap.c
@@ -255,13 +255,10 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
255 goto out; 255 goto out;
256 if (len == 0) 256 if (len == 0)
257 set_bit(CACHE_NEGATIVE, &ent.h.flags); 257 set_bit(CACHE_NEGATIVE, &ent.h.flags);
258 else { 258 else if (len >= IDMAP_NAMESZ)
259 if (error >= IDMAP_NAMESZ) { 259 goto out;
260 error = -EINVAL; 260 else
261 goto out;
262 }
263 memcpy(ent.name, buf1, sizeof(ent.name)); 261 memcpy(ent.name, buf1, sizeof(ent.name));
264 }
265 error = -ENOMEM; 262 error = -ENOMEM;
266 res = idtoname_update(&ent, res); 263 res = idtoname_update(&ent, res);
267 if (res == NULL) 264 if (res == NULL)
@@ -467,20 +464,25 @@ nametoid_update(struct ent *new, struct ent *old)
467 * Exported API 464 * Exported API
468 */ 465 */
469 466
470void 467int
471nfsd_idmap_init(void) 468nfsd_idmap_init(void)
472{ 469{
473 cache_register(&idtoname_cache); 470 int rv;
474 cache_register(&nametoid_cache); 471
472 rv = cache_register(&idtoname_cache);
473 if (rv)
474 return rv;
475 rv = cache_register(&nametoid_cache);
476 if (rv)
477 cache_unregister(&idtoname_cache);
478 return rv;
475} 479}
476 480
477void 481void
478nfsd_idmap_shutdown(void) 482nfsd_idmap_shutdown(void)
479{ 483{
480 if (cache_unregister(&idtoname_cache)) 484 cache_unregister(&idtoname_cache);
481 printk(KERN_ERR "nfsd: failed to unregister idtoname cache\n"); 485 cache_unregister(&nametoid_cache);
482 if (cache_unregister(&nametoid_cache))
483 printk(KERN_ERR "nfsd: failed to unregister nametoid cache\n");
484} 486}
485 487
486/* 488/*