On Mon, Oct 24, 2005 at 03:56:47AM -0500, Hareesh Nagarajan wrote:Matt Mackall wrote:On Mon, Oct 24, 2005 at 12:29:45AM -0500, Hareesh Nagarajan wrote:The existing code in init_tmpfs() in mm/tiny-shmem.c does not handle the cases when the calls to register_filesystem() and kern_mount() fail. This patch adds those checks.
A couple more comments..
Signed-off-by: Hareesh Nagarajan <hnagar2@xxxxxxxxx>
--- linux-2.6.13.4/mm/tiny-shmem.c 2005-10-10 13:54:29.000000000 -0500
+++ linux-2.6.13.4-edit/mm/tiny-shmem.c 2005-10-24 03:43:38.614071000 -0500
@@ -31,12 +31,18 @@
static int __init init_tmpfs(void)
{
- register_filesystem(&tmpfs_fs_type);
+ int error;
+
+ error = register_filesystem(&tmpfs_fs_type);
+ BUG_ON(error);
Can we just do BUG_ON(register_filesystem() != 0)?
Strictly speaking, the != 0 is redundant, but as this goes slightly
against the grain of normal usage, it's a good indicator of intent.
#ifdef CONFIG_TMPFS
devfs_mk_dir("shm");
#endif
shm_mnt = kern_mount(&tmpfs_fs_type);
- return 0;
+ BUG_ON(IS_ERR(shm_mnt));
+
+ return error;
We can never return non-zero here. Returning error implies we can, so
it's confusing.