summary refs log tree commit diff
path: root/fs/jfs/jfs_txnmgr.c
diff options
context:
space:
mode:
authorImmad Mir <mirimmad17@gmail.com>2023-06-23 19:17:08 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-07-27 08:50:33 +0200
commitaa7cdf487ab3fa47284daaccc3d7d5de01c6a84c (patch)
treefe816577282c7622f6f45cd1d5791c8a542c4bfd /fs/jfs/jfs_txnmgr.c
parent3e5eb6c5ecd8ddb9cfea751cf30f9e23eac97ca3 (diff)
downloadlinux-aa7cdf487ab3fa47284daaccc3d7d5de01c6a84c.tar.gz
FS: JFS: Check for read-only mounted filesystem in txBegin
[ Upstream commit 95e2b352c03b0a86c5717ba1d24ea20969abcacc ]

 This patch adds a check for read-only mounted filesystem
 in txBegin before starting a transaction potentially saving
 from NULL pointer deref.

Signed-off-by: Immad Mir <mirimmad17@gmail.com>
Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/jfs/jfs_txnmgr.c')
-rw-r--r--fs/jfs/jfs_txnmgr.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c
index ffd4feece078..ce4b4760fcb1 100644
--- a/fs/jfs/jfs_txnmgr.c
+++ b/fs/jfs/jfs_txnmgr.c
@@ -354,6 +354,11 @@ tid_t txBegin(struct super_block *sb, int flag)
 	jfs_info("txBegin: flag = 0x%x", flag);
 	log = JFS_SBI(sb)->log;
 
+	if (!log) {
+		jfs_error(sb, "read-only filesystem\n");
+		return 0;
+	}
+
 	TXN_LOCK();
 
 	INCREMENT(TxStat.txBegin);