[TRIVIAL] Error checks omitted in init_tmpfs() in mm/tiny-shmem.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: Hareesh Nagarajan <[email protected]>

--- 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 00:13:10.532652000 -0500
@@ -31,12 +31,27 @@
 
 static int __init init_tmpfs(void)
 {
-	register_filesystem(&tmpfs_fs_type);
+	int error;
+
+	error = register_filesystem(&tmpfs_fs_type);
+	if (error) {
+		goto out2;
+	}
+
 #ifdef CONFIG_TMPFS
 	devfs_mk_dir("shm");
 #endif
 	shm_mnt = kern_mount(&tmpfs_fs_type);
+	if (IS_ERR(shm_mnt)) {
+		error = PTR_ERR(shm_mnt);
+		goto out1;
+	}
+
 	return 0;
+out1:
+	unregister_filesystem(&tmpfs_fs_type);
+out2:
+	return error;
 }
 module_init(init_tmpfs)
 

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux