exfat: Fix potential use after free in exfat_load_upcase_table()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 8 Jun 2020 14:16:29 +0000 (17:16 +0300)
committerNamjae Jeon <namjae.jeon@samsung.com>
Tue, 9 Jun 2020 07:50:18 +0000 (16:50 +0900)
This code calls brelse(bh) and then dereferences "bh" on the next line
resulting in a possible use after free.  The brelse() should just be
moved down a line.

Fixes: b676fdbcf4c8 ("exfat: standardize checksum calculation")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
fs/exfat/nls.c

index c1ec056..57b5a7a 100644 (file)
@@ -692,8 +692,8 @@ static int exfat_load_upcase_table(struct super_block *sb,
                                index++;
                        }
                }
-               brelse(bh);
                chksum = exfat_calc_chksum32(bh->b_data, i, chksum, CS_DEFAULT);
+               brelse(bh);
        }
 
        if (index >= 0xFFFF && utbl_checksum == chksum)