From: Heinrich Schuchardt Date: Sat, 26 Oct 2024 06:40:45 +0000 (+0200) Subject: fs: ext4: free directory node in ext4fs_exists() X-Git-Url: http://git.dujemihanovic.xyz/%7B%7B%20%24style.RelPermalink%20%7D%7D?a=commitdiff_plain;h=2d94480c025faf11d2e1010f5437e72d8e934127;p=u-boot.git fs: ext4: free directory node in ext4fs_exists() The directory retrieved in ext4fs_exists() should be freed to avoid a memory leak. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Reviewed-by: Michael Trimarchi Reviewed-by: Ilias Apalodimas --- diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c index 15587e92e3..21714149ef 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; } int ext4fs_size(const char *filename, loff_t *size)