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>
if (!ctx)
return -ENOMEM;
+ fc->ops = &v9fs_context_ops;
+ fc->fs_private = ctx;
+
/* initialize core options */
ctx->session_opts.afid = ~0;
ctx->session_opts.cache = CACHE_NONE;
ctx->rdma_opts.timeout = P9_RDMA_TIMEOUT;
ctx->rdma_opts.privport = false;
- fc->ops = &v9fs_context_ops;
- fc->fs_private = ctx;
-
return 0;
error:
fc->need_free = 1;