]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
9p: fix memory leak in v9fs_init_fs_context error path
authorSasha Levin <sashal@kernel.org>
Wed, 25 Feb 2026 13:57:45 +0000 (08:57 -0500)
committerDominique Martinet <asmadeus@codewreck.org>
Thu, 16 Apr 2026 01:53:42 +0000 (01:53 +0000)
commit0fd76f1be20d19ac593138ceec502cb044c909bd
treecab73ab5137f385146aa08e3b67d0bff56e21f4d
parent028ef9c96e96197026887c0f092424679298aae8
9p: fix memory leak in v9fs_init_fs_context error path

Move the assignments of fc->ops and fc->fs_private to right after the
kzalloc, before any fallible operations. Previously these were assigned
at the end of the function, after the kstrdup calls for uname and aname.
If either kstrdup failed, the error path would set fc->need_free but
leave fc->ops NULL, so put_fs_context() would never call v9fs_free_fc()
to free the allocated context and any already-duplicated strings.

Fixes: 1f3e4142c0eb ("9p: convert to the new mount API")
Assisted-by: Claude:claude-opus-4-6
Signed-off-by: Sasha Levin <sashal@kernel.org>
Message-ID: <20260225135745.351984-1-sashal@kernel.org>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
fs/9p/vfs_super.c