diff mbox series

[15/17] fs/squashfs: sqfs_read: fix memory leak

Message ID 20201014080622.14970-16-richard.genoud@posteo.net
State Superseded
Delegated to: Tom Rini
Headers show
Series fs/squashfs: fix memory leaks and introduce exists() function | expand

Commit Message

Richard Genoud Oct. 14, 2020, 8:06 a.m. UTC
sqfs_closedir() should be called to free memory allocated by
sqfs_opendir()

Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
---
 fs/squashfs/sqfs.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Richard Genoud Oct. 16, 2020, 2:49 p.m. UTC | #1
Le 14/10/2020 à 10:06, Richard Genoud a écrit :
> sqfs_closedir() should be called to free memory allocated by
> sqfs_opendir()
> 
> Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
> ---
>   fs/squashfs/sqfs.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c
> index 79d68dddb28..6cd3ba9ce10 100644
> --- a/fs/squashfs/sqfs.c
> +++ b/fs/squashfs/sqfs.c
> @@ -1531,6 +1531,7 @@ free_datablk:
>   free_paths:
>   	free(file);
>   	free(dir);
> +	sqfs_closedir(dirsp);

I forgot to remove a sqfs_closedir(dirsp); at the begining of the sqfs_read() function.
So this could lead to a double free.
I'll add it in next version.

>   
>   	return ret;
>   }
>
diff mbox series

Patch

diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c
index 79d68dddb28..6cd3ba9ce10 100644
--- a/fs/squashfs/sqfs.c
+++ b/fs/squashfs/sqfs.c
@@ -1531,6 +1531,7 @@  free_datablk:
 free_paths:
 	free(file);
 	free(dir);
+	sqfs_closedir(dirsp);
 
 	return ret;
 }