]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fs: ext4: free directory node in ext4fs_exists()
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sat, 26 Oct 2024 06:40:45 +0000 (08:40 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 1 Nov 2024 19:37:58 +0000 (13:37 -0600)
The directory retrieved in ext4fs_exists() should be freed to avoid a
memory leak.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
fs/ext4/ext4fs.c

index 15587e92e3e72d02206ddffe9c60733dc1df475b..21714149ef59d524c1c39377229ae6ec4c1ef9ba 100644 (file)
@@ -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;
 }
 
 int ext4fs_size(const char *filename, loff_t *size)