]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
fs: ext4fs: Fix: Data abort in ext4fs_log_gdt()
authorTony Dinh <mibodhi@gmail.com>
Tue, 3 Jun 2025 04:50:22 +0000 (21:50 -0700)
committerTom Rini <trini@konsulko.com>
Wed, 25 Jun 2025 19:41:35 +0000 (13:41 -0600)
Return ENOMEM in ext4fs_log_gdt when number of blocks per gdt is more than
number of allocated journal entries.

Signed-off-by: Tony Dinh <mibodhi@gmail.com>
fs/ext4/ext4_journal.c

index 02c4ac2cb931b866d690461da1dcbb6054b143f4..868a2c1804a5bc7eca6ac271229e890e291144b5 100644 (file)
@@ -131,6 +131,13 @@ int ext4fs_log_gdt(char *gd_table)
        struct ext_filesystem *fs = get_fs();
        short i;
        long int var = fs->gdtable_blkno;
+
+       /* Make sure there is enough journal entries */
+       if (fs->no_blk_pergdt > MAX_JOURNAL_ENTRIES) {
+               log_err("*** Not enough journal entries allocated\n");
+               return -ENOMEM;
+       }
+
        for (i = 0; i < fs->no_blk_pergdt; i++) {
                journal_ptr[gindex]->buf = zalloc(fs->blksz);
                if (!journal_ptr[gindex]->buf)