Re: [PATCH] 9p: fix memory leak in v9fs_init_fs_context error path

From: Dominique Martinet

Date: Wed Feb 25 2026 - 09:10:10 EST


Sasha Levin wrote on Wed, Feb 25, 2026 at 08:57:45AM -0500:
> 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@xxxxxxxxxx>

Looks correct to me (and there doesn't seem to be any side effect of
settings ops in the error path)

Pushed to my -next branch, will submit eventually.

Thanks!
--
Dominique