mbcache: don't BUG() if entry cache cannot be allocated
authorEric Biggers <ebiggers@google.com>
Sat, 3 Dec 2016 20:28:53 +0000 (15:28 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 3 Dec 2016 20:28:53 +0000 (15:28 -0500)
mbcache can be a module that is loaded long after startup, when someone
asks to mount an ext2 or ext4 filesystem.  Therefore it should not BUG()
if kmem_cache_create() fails, but rather just fail the module load.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Jan Kara <jack@suse.cz>
fs/mbcache.c

index 31e54c2..c56ab21 100644 (file)
@@ -420,7 +420,8 @@ static int __init mbcache_init(void)
        mb_entry_cache = kmem_cache_create("mbcache",
                                sizeof(struct mb_cache_entry), 0,
                                SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL);
-       BUG_ON(!mb_entry_cache);
+       if (!mb_entry_cache)
+               return -ENOMEM;
        return 0;
 }