Skip to contentSkip to conversation

exfat: fix possible memory leak in exfat_find()

PATCH Applied Wei Yongjun 2 participants 2 messages May 6, 2020 – May 7, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 exfat: fix possible memory leak in exfat_find()

'es' is malloced from exfat_get_dentry_set() in exfat_find() and should be freed before leaving from the error handling cases, otherwise it will cause memory leak.

Fixes 5f2aa075070c ("exfat: add inode operations")
---
 fs/exfat/namei.c | 1 +
 1 file changed, 1 insertion(+)
fs/exfat/namei.c +1 -0
index c241dd177f1a..48f4df883f3b 100644
@@ -681,6 +681,7 @@ static int exfat_find(struct inode *dir, struct qstr *qname,
 			exfat_fs_error(sb,
 				"non-zero size file starts with zero cluster (size : %llu, p_dir : %u, entry : 0x%08x)",
 				i_size_read(dir), ei->dir.dir, ei->entry);
+			kfree(es);
 			return -EIO;
 		}
 
Applied
#1 lore raw
Quoted 5 lines

'es' is malloced from exfat_get_dentry_set() in exfat_find() and should be freed before leaving from the error handling cases, otherwise it will cause memory leak.

Fixes 5f2aa075070c ("exfat: add inode operations")

Applied.
Thanks!

Quoted 17 lines
---
 fs/exfat/namei.c | 1 +
 1 file changed, 1 insertion(+)
fs/exfat/namei.c +1 -0
@@ -681,6 +681,7 @@ static int exfat_find(struct inode *dir, struct qstr *qname,
 			exfat_fs_error(sb,
 				"non-zero size file starts with zero cluster (size : %llu, p_dir : %u,
 entry : 0x%08x)",
 				i_size_read(dir), ei->dir.dir, ei->entry);
+			kfree(es);
 			return -EIO;
 		}