diff options
author | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2024-10-26 08:40:45 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-11-01 13:37:58 -0600 |
commit | 2d94480c025faf11d2e1010f5437e72d8e934127 (patch) | |
tree | 4303c2d929be507fdffe5c3ac978f5c237e39b20 | |
parent | a1a86a1784ef8a488f9af024dcc3de57924c354e (diff) |
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 <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>
-rw-r--r-- | fs/ext4/ext4fs.c | 9 |
1 files 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; } int ext4fs_size(const char *filename, loff_t *size) |