FS: JFS: Check for read-only mounted filesystem in txBegin
authorImmad Mir <mirimmad17@gmail.com>
Fri, 23 Jun 2023 13:47:08 +0000 (19:17 +0530)
committerDave Kleikamp <dave.kleikamp@oracle.com>
Fri, 23 Jun 2023 14:02:33 +0000 (09:02 -0500)
 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>
fs/jfs/jfs_txnmgr.c

index ffd4feece0785a181085d060291ffbc82399d024..ce4b4760fcb1d6402a3220887e10fd9f97e61e4a 100644 (file)
@@ -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);