git: b9f1f9b60c6f - stable/15 - fix p9fs_vget_common() panics
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 02 Nov 2026 10:45:51 UTC
The branch stable/15 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=b9f1f9b60c6f7ddff4fa87de161a62ef1ed3a859
commit b9f1f9b60c6f7ddff4fa87de161a62ef1ed3a859
Author: Nimish Jain <njain15@protonmail.com>
AuthorDate: 2026-08-03 23:08:31 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-11-02 10:39:49 +0000
fix p9fs_vget_common() panics
(cherry picked from commit 2d21dbaaaf75558b42a000561eb6224b6c1c0615)
---
sys/fs/p9fs/p9fs_vfsops.c | 56 +++++++++++++----------------------------------
sys/fs/p9fs/p9fs_vnops.c | 3 ---
2 files changed, 15 insertions(+), 44 deletions(-)
diff --git a/sys/fs/p9fs/p9fs_vfsops.c b/sys/fs/p9fs/p9fs_vfsops.c
index 94a67fdef428..697a86595edf 100644
--- a/sys/fs/p9fs/p9fs_vfsops.c
+++ b/sys/fs/p9fs/p9fs_vfsops.c
@@ -259,7 +259,7 @@ p9fs_vget_common(struct mount *mp, struct p9fs_node *np, int flags,
struct p9fs_node *node;
struct thread *td;
uint32_t hash;
- int error, error_reload = 0;
+ int error;
struct p9fs_inode *inode;
td = curthread;
@@ -348,57 +348,31 @@ p9fs_vget_common(struct mount *mp, struct p9fs_node *np, int flags,
if (vp->v_type != VFIFO)
VN_LOCK_ASHARE(vp);
error = insmntque(vp, mp);
- if (error != 0) {
- /*
- * vput(vp) is already called from insmntque_stddtr().
- * Just goto 'out' to dispose the node.
- */
- goto out;
- }
+ if (error != 0)
+ return (error);
/* Init the vnode with the disk info*/
error = p9fs_reload_stats_dotl(vp, curthread->td_ucred);
if (error != 0) {
- error_reload = 1;
- goto out;
+ P9FS_NODE_SETF(np, P9FS_NODE_DELETED);
+ vgone(vp);
+ vput(vp);
+ return (error);
}
error = vfs_hash_insert(vp, hash, flags, td, vpp,
p9fs_node_cmp, &fid->qid);
- if (error != 0) {
- goto out;
- }
+ if (error != 0 || *vpp != NULL)
+ return (error);
- if (*vpp == NULL) {
- P9FS_LOCK(vses);
- STAILQ_INSERT_TAIL(&vses->virt_node_list, np, p9fs_node_next);
- P9FS_NODE_SETF(np, P9FS_NODE_IN_SESSION);
- P9FS_UNLOCK(vses);
- vn_set_state(vp, VSTATE_CONSTRUCTED);
- *vpp = vp;
- } else {
- /*
- * Returning matching vp found in hashlist.
- * So cleanup the np allocated above in this context.
- */
- if (!IS_ROOT(np)) {
- p9fs_destroy_node(&np);
- }
- }
+ P9FS_LOCK(vses);
+ STAILQ_INSERT_TAIL(&vses->virt_node_list, np, p9fs_node_next);
+ P9FS_NODE_SETF(np, P9FS_NODE_IN_SESSION);
+ P9FS_UNLOCK(vses);
+ vn_set_state(vp, VSTATE_CONSTRUCTED);
+ *vpp = vp;
return (0);
-out:
- /* Something went wrong, dispose the node */
- if (!IS_ROOT(np)) {
- p9fs_destroy_node(&np);
- }
-
- if (error_reload) {
- vput(vp);
- }
-
- *vpp = NULLVP;
- return (error);
}
/* Main mount function for 9pfs */
diff --git a/sys/fs/p9fs/p9fs_vnops.c b/sys/fs/p9fs/p9fs_vnops.c
index 0ac86343649f..f795371bb7ea 100644
--- a/sys/fs/p9fs/p9fs_vnops.c
+++ b/sys/fs/p9fs/p9fs_vnops.c
@@ -113,9 +113,6 @@ p9fs_cleanup(struct p9fs_node *np)
if ((np->flags & P9FS_NODE_IN_SESSION) != 0) {
P9FS_NODE_CLRF(np, P9FS_NODE_IN_SESSION);
STAILQ_REMOVE(&vses->virt_node_list, np, p9fs_node, p9fs_node_next);
- } else {
- P9FS_UNLOCK(vses);
- return;
}
P9FS_UNLOCK(vses);