Skip to contentSkip to conversation

panic() instead of crashing on a null pointer deref in mount_block_root()

PATCH New Jesper Juhl 1 participant 1 message May 14, 2006 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 panic() instead of crashing on a null pointer deref in mount_block_root()

If __getname() fails in mount_block_root() we are dead in the water, but a panic() seems a little nicer than crashing due to a NULL pointer deref.

---

 init/do_mounts.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)
init/do_mounts.c +2 -1
@@ -286,6 +286,8 @@ void __init mount_block_root(char *name,
 	char *p;
 	char b[BDEVNAME_SIZE];
 
+	if (!fs_names)
+		panic("VFS: Failed memory allocation in mount_block_root()");
 	get_fs_names(fs_names);
 retry:
 	for (p = fs_names; *p; p += strlen(p)+1) {
@@ -425,4 +427,3 @@ out:
 	security_sb_post_mountroot();
 	mount_devfs_fs ();
 }
-