Skip to content

Commit d2b537b

Browse files
YuezhangMonamjaejeon
authored andcommitted
exfat: fix memory leak in exfat_load_bitmap()
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: stable@vger.kernel.org Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com> Reviewed-by: Aoyama Wataru <wataru.aoyama@sony.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
1 parent f761fcd commit d2b537b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

fs/exfat/balloc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,18 @@ int exfat_load_bitmap(struct super_block *sb)
9191
return -EIO;
9292

9393
type = exfat_get_entry_type(ep);
94-
if (type == TYPE_UNUSED)
95-
break;
96-
if (type != TYPE_BITMAP)
97-
continue;
98-
if (ep->dentry.bitmap.flags == 0x0) {
94+
if (type == TYPE_BITMAP &&
95+
ep->dentry.bitmap.flags == 0x0) {
9996
int err;
10097

10198
err = exfat_allocate_bitmap(sb, ep);
10299
brelse(bh);
103100
return err;
104101
}
105102
brelse(bh);
103+
104+
if (type == TYPE_UNUSED)
105+
return -EINVAL;
106106
}
107107

108108
if (exfat_get_next_cluster(sb, &clu.dir))

0 commit comments

Comments
 (0)