diff mbox series

[-next] exfat: fix possible memory leak in exfat_find()

Message ID 20200506142554.123748-1-weiyongjun1@huawei.com
State New, archived
Headers show
Series [-next] exfat: fix possible memory leak in exfat_find() | expand

Commit Message

Wei Yongjun May 6, 2020, 2:25 p.m. UTC
'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")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 fs/exfat/namei.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Namjae Jeon May 7, 2020, 2:50 a.m. UTC | #1
> '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")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Applied.
Thanks!
> ---
>  fs/exfat/namei.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index c241dd177f1a..48f4df883f3b 100644
> --- a/fs/exfat/namei.c
> +++ b/fs/exfat/namei.c
> @@ -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;
>  		}
> 
>
diff mbox series

Patch

diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
index c241dd177f1a..48f4df883f3b 100644
--- a/fs/exfat/namei.c
+++ b/fs/exfat/namei.c
@@ -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;
 		}