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; }