Skip to content

Commit

Permalink
exfat: fix memory leak in exfat_load_bitmap()
Browse files Browse the repository at this point in the history
commit d2b537b upstream.

If the first directory entry in the root directory is not a bitmap
directory entry, 'bh' will not be released and reassigned, which
will cause a memory leak.

Fixes: 1e49a94 ("exfat: add bitmap operations")
Cc: [email protected]
Signed-off-by: Yuezhang Mo <[email protected]>
Reviewed-by: Aoyama Wataru <[email protected]>
Signed-off-by: Namjae Jeon <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
YuezhangMo authored and gregkh committed Oct 10, 2024
1 parent 131d2cd commit 89081e8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions fs/exfat/balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,18 @@ int exfat_load_bitmap(struct super_block *sb)
return -EIO;

type = exfat_get_entry_type(ep);
if (type == TYPE_UNUSED)
break;
if (type != TYPE_BITMAP)
continue;
if (ep->dentry.bitmap.flags == 0x0) {
if (type == TYPE_BITMAP &&
ep->dentry.bitmap.flags == 0x0) {
int err;

err = exfat_allocate_bitmap(sb, ep);
brelse(bh);
return err;
}
brelse(bh);

if (type == TYPE_UNUSED)
return -EINVAL;
}

if (exfat_get_next_cluster(sb, &clu.dir))
Expand Down

0 comments on commit 89081e8

Please sign in to comment.