Skip to content

Commit c8d826f

Browse files
YuezhangMomehmetb0
authored andcommitted
exfat: fix memory leak in exfat_load_bitmap()
BugLink: https://bugs.launchpad.net/bugs/2086242 commit d2b537b3e533f28e0d97293fe9293161fe8cd137 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]> Signed-off-by: Koichiro Den <[email protected]> Signed-off-by: Roxana Nicolescu <[email protected]>
1 parent 859c6b1 commit c8d826f

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
@@ -110,18 +110,18 @@ int exfat_load_bitmap(struct super_block *sb)
110110
return -EIO;
111111

112112
type = exfat_get_entry_type(ep);
113-
if (type == TYPE_UNUSED)
114-
break;
115-
if (type != TYPE_BITMAP)
116-
continue;
117-
if (ep->dentry.bitmap.flags == 0x0) {
113+
if (type == TYPE_BITMAP &&
114+
ep->dentry.bitmap.flags == 0x0) {
118115
int err;
119116

120117
err = exfat_allocate_bitmap(sb, ep);
121118
brelse(bh);
122119
return err;
123120
}
124121
brelse(bh);
122+
123+
if (type == TYPE_UNUSED)
124+
return -EINVAL;
125125
}
126126

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

0 commit comments

Comments
 (0)