[PATCH 2/5] fs: ext4: free directory node in ext4fs_exists()
Michael Nazzareno Trimarchi
michael at amarulasolutions.com
Sat Oct 26 10:53:06 CEST 2024
Hi
On Sat, Oct 26, 2024 at 8:42 AM Heinrich Schuchardt
<heinrich.schuchardt at canonical.com> wrote:
>
> The directory retrieved in ext4fs_exists() should be freed to avoid a
> memory leak.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
> ---
> fs/ext4/ext4fs.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
> index 15587e92e3e..21714149ef5 100644
> --- a/fs/ext4/ext4fs.c
> +++ b/fs/ext4/ext4fs.c
> @@ -209,12 +209,17 @@ int ext4fs_exists(const char *filename)
> {
> struct ext2fs_node *dirnode = NULL;
> int filetype;
> + int ret;
>
> if (!filename)
> return 0;
>
> - return ext4fs_find_file1(filename, &ext4fs_root->diropen, &dirnode,
> - &filetype);
> + ret = ext4fs_find_file1(filename, &ext4fs_root->diropen, &dirnode,
> + &filetype);
> + if (dirnode)
> + ext4fs_free_node(dirnode, &ext4fs_root->diropen);
> +
> + return ret;
> }
>
Reviewed-by: Michael Trimarchi <michael at amarulasolutions.com>
> int ext4fs_size(const char *filename, loff_t *size)
> --
> 2.45.2
>
--
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael at amarulasolutions.com
__________________________________
Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info at amarulasolutions.com
www.amarulasolutions.com
More information about the U-Boot
mailing list