History

exfat: resolve memory leak from exfat_create_upcase_table()

If exfat_load_upcase_table reaches end and returns -EINVAL, allocated memory doesn't get freed and while exfat_load_default_upcase_table allocates more memory, leading to a memory leak. Here's link to syzkaller crash report illustrating this issue: https://syzkaller.appspot.com/text?tag=CrashReport&x=1406c201980000

Daniel Yang committed 2 years ago

Commit c290fe51 parent 6630ea41 file · +4 −1Browse files

Unified · Split

fs/exfat/nls.c+4−1
@@ -779,8 +779,11 @@ int exfat_create_upcase_table(struct super_block *sb) · 778 unmodified lines
779779 le32_to_cpu(ep->dentry.upcase.checksum));
780780
781781 brelse(bh);
782− if (ret && ret != -EIO)
782+ if (ret && ret != -EIO) {
783+ /* free memory from exfat_load_upcase_table call */
784+ exfat_free_upcase_table(sbi);
783785 goto load_default;
786+ }
784787
785788 /* load successfully */
786789 return ret;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t