From: Jeff Layton Date: Thu, 2 Aug 2012 18:30:56 +0000 (-0400) Subject: nfs: tear down caches in nfs_init_writepagecache when allocation fails X-Git-Tag: v3.4.81~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=478b97d4d7c5468e2ea21ad34d344a4dac5ff230;p=thirdparty%2Fkernel%2Fstable.git nfs: tear down caches in nfs_init_writepagecache when allocation fails commit 3dd4765fce04c0b4af1e0bc4c0b10f906f95fabc upstream. ...and ensure that we tear down the nfs_commit_data cache too when unloading the module. Cc: Bryan Schumaker Signed-off-by: Jeff Layton Signed-off-by: Trond Myklebust [bwh: Backported to 3.2: drop the nfs_cdata_cachep cleanup; it doesn't exist] Signed-off-by: Ben Hutchings Cc: Li Zefan Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/nfs/write.c b/fs/nfs/write.c index c07462320f6b5..da8fd94fcd93c 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -1751,12 +1751,12 @@ int __init nfs_init_writepagecache(void) nfs_wdata_mempool = mempool_create_slab_pool(MIN_POOL_WRITE, nfs_wdata_cachep); if (nfs_wdata_mempool == NULL) - return -ENOMEM; + goto out_destroy_write_cache; nfs_commit_mempool = mempool_create_slab_pool(MIN_POOL_COMMIT, nfs_wdata_cachep); if (nfs_commit_mempool == NULL) - return -ENOMEM; + goto out_destroy_write_mempool; /* * NFS congestion size, scale with available memory. @@ -1779,6 +1779,12 @@ int __init nfs_init_writepagecache(void) nfs_congestion_kb = 256*1024; return 0; + +out_destroy_write_mempool: + mempool_destroy(nfs_wdata_mempool); +out_destroy_write_cache: + kmem_cache_destroy(nfs_wdata_cachep); + return -ENOMEM; } void nfs_destroy_writepagecache(void)