git: b39457bb1566 - main - virtio_p9fs: Disallow detach if a session is in progress

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 18 Aug 2026 14:43:27 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=b39457bb1566912062b2df551b7b8d429b8ba0da

commit b39457bb1566912062b2df551b7b8d429b8ba0da
Author:     Nimish Jain <njain15@protonmail.com>
AuthorDate: 2026-08-18 14:41:38 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-08-18 14:43:16 +0000

    virtio_p9fs: Disallow detach if a session is in progress
    
    PR:             295453
    Reviewed by:    markj
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D57500
---
 sys/dev/virtio/p9fs/virtio_p9fs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/dev/virtio/p9fs/virtio_p9fs.c b/sys/dev/virtio/p9fs/virtio_p9fs.c
index 7a5d703513c0..37520bb25c76 100644
--- a/sys/dev/virtio/p9fs/virtio_p9fs.c
+++ b/sys/dev/virtio/p9fs/virtio_p9fs.c
@@ -271,6 +271,10 @@ vt9p_detach(device_t dev)
 	struct vt9p_softc *sc;
 
 	sc = device_get_softc(dev);
+
+	if (sc->busy)
+		return (EBUSY);
+
 	VT9P_LOCK(sc);
 	vt9p_stop(sc);
 	VT9P_UNLOCK(sc);