Skip to content

Commit

Permalink
ubifs: fix to check error code of register_shrinker
Browse files Browse the repository at this point in the history
register_shrinker() in ubifs_init() can fail due to fail to call kzalloc.
This patch fixes to check the return value of register_shrinker, otherwise
our shrinker may be unregistered after ubifs initialized successfully.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
  • Loading branch information
Chao Yu authored and Richard Weinberger committed Jun 2, 2015
1 parent 2bf50d4 commit a1fe33a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/ubifs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2245,7 +2245,9 @@ static int __init ubifs_init(void)
if (!ubifs_inode_slab)
return -ENOMEM;

register_shrinker(&ubifs_shrinker_info);
err = register_shrinker(&ubifs_shrinker_info);
if (err)
goto out_slab;

err = ubifs_compressors_init();
if (err)
Expand All @@ -2269,6 +2271,7 @@ static int __init ubifs_init(void)
ubifs_compressors_exit();
out_shrinker:
unregister_shrinker(&ubifs_shrinker_info);
out_slab:
kmem_cache_destroy(ubifs_inode_slab);
return err;
}
Expand Down

0 comments on commit a1fe33a

Please sign in to comment.