From 01dcf95edf0263c7f29caa7a0477ab1b8c4c7ca7 Mon Sep 17 00:00:00 2001 From: Namjae Jeon Date: Sat, 19 Oct 2024 12:59:05 +0900 Subject: [PATCH] exfat: fix uninit-value use in __exfat_get_dentry_set Signed-off-by: Namjae Jeon --- fs/exfat/dir.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 7446bf09a04a..8ee3c99e2666 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -741,9 +741,15 @@ static bool exfat_validate_entry(unsigned int type, struct exfat_dentry *exfat_get_dentry_cached( struct exfat_entry_set_cache *es, int num) { - int off = es->start_off + num * DENTRY_SIZE; - struct buffer_head *bh = es->bh[EXFAT_B_TO_BLK(off, es->sb)]; - char *p = bh->b_data + EXFAT_BLK_OFFSET(off, es->sb); + struct buffer_head *bh; + int off; + char *p; + + if (check_add_overflow(es->start_off, num * DENTRY_SIZE, &off)) + return NULL; + + bh = es->bh[EXFAT_B_TO_BLK(off, es->sb)]; + p = bh->b_data + EXFAT_BLK_OFFSET(off, es->sb); return (struct exfat_dentry *)p; } -- 2.25.1