Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Sasha Levin and committed by
Dominique Martinet
0fd76f1b 028ef9c9

+3 -3
+3 -3
fs/9p/vfs_super.c
··· 312 312 if (!ctx) 313 313 return -ENOMEM; 314 314 315 + fc->ops = &v9fs_context_ops; 316 + fc->fs_private = ctx; 317 + 315 318 /* initialize core options */ 316 319 ctx->session_opts.afid = ~0; 317 320 ctx->session_opts.cache = CACHE_NONE; ··· 347 344 ctx->rdma_opts.rq_depth = P9_RDMA_RQ_DEPTH; 348 345 ctx->rdma_opts.timeout = P9_RDMA_TIMEOUT; 349 346 ctx->rdma_opts.privport = false; 350 - 351 - fc->ops = &v9fs_context_ops; 352 - fc->fs_private = ctx; 353 347 354 348 return 0; 355 349 error: