[PATCH] Avoid segfault when dirty inodes are written on readonly mount (1 of 1)

Dave Kleikamp <[email protected]> Tue, 25 Nov 2003 12:18:40 -0600
Newsgroups gmane.comp.file-systems.jfs.patches
Message-ID <[email protected]>
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.1192  -> 1.1193 
#	 fs/jfs/jfs_logmgr.c	1.19    -> 1.20   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/11/25	[email protected]	1.1193
# JFS: Avoid segfault when dirty inodes are written on readonly mount
#    
# Writes to a device may cause a ->write_inode to be called during a read-only
# mount.  JFS needs to check for NULL log in jfs_flush_journal.
# --------------------------------------------
#
diff -Nru a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
--- a/fs/jfs/jfs_logmgr.c	Tue Nov 25 12:02:53 2003
+++ b/fs/jfs/jfs_logmgr.c	Tue Nov 25 12:02:53 2003
@@ -1409,6 +1409,10 @@
 	int i;
 	struct tblock *target;
 
+	if (!log)
+		/* jfs_write_inode may call us during read-only mount */
+		return;
+
 	jfs_info("jfs_flush_journal: log:0x%p wait=%d", log, wait);
 
 	LOGGC_LOCK(log);