* [PATCH] fs: fix memory leak in automount_add()
@ 2026-05-07 11:54 Ahmad Fatoum
0 siblings, 0 replies; only message in thread
From: Ahmad Fatoum @ 2026-05-07 11:54 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
The struct automount is allocated before validating the path, but both
error paths (filename_lookup failure and !d_is_dir check) skip freeing
it. Move the allocation after validation succeeds.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
fs/fs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/fs.c b/fs/fs.c
index 5ca98ec12704..dc6c30802d89 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -3450,7 +3450,7 @@ EXPORT_SYMBOL(automount_remove);
int automount_add(const char *pathname, const char *cmd)
{
- struct automount *am = xzalloc(sizeof(*am));
+ struct automount *am;
struct path path;
int ret;
@@ -3463,6 +3463,7 @@ int automount_add(const char *pathname, const char *cmd)
goto out;
}
+ am = xzalloc(sizeof(*am));
am->path = dpath(path.dentry, d_root);
am->dentry = dget(path.dentry);
am->dentry->d_flags |= DCACHE_NEED_AUTOMOUNT;
--
2.47.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-05-07 11:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-07 11:54 [PATCH] fs: fix memory leak in automount_add() Ahmad Fatoum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox