git: f96c4f45f791 - main - cuse: Assert the server refcount
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 30 Sep 2026 09:51:31 UTC
The branch main has been updated by christos:
URL: https://cgit.FreeBSD.org/src/commit/?id=f96c4f45f791124192363c9aa2898b1d0e4cc6d0
commit f96c4f45f791124192363c9aa2898b1d0e4cc6d0
Author: Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2026-09-30 09:51:05 +0000
Commit: Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2026-09-30 09:51:05 +0000
cuse: Assert the server refcount
Assert that the refcount does not underflow before decrementing it, and
that it really is zero by the time the server is freed.
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D60043
---
sys/fs/cuse/cuse.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sys/fs/cuse/cuse.c b/sys/fs/cuse/cuse.c
index 081fe1fe0bad..7408478f4ba7 100644
--- a/sys/fs/cuse/cuse.c
+++ b/sys/fs/cuse/cuse.c
@@ -648,6 +648,7 @@ cuse_server_unref(struct cuse_server *pcs)
*/
cuse_global_lock();
cuse_server_lock(pcs);
+ MPASS(pcs->refs > 0);
if (--(pcs->refs) != 0) {
cuse_server_unlock(pcs);
cuse_global_unlock();
@@ -683,6 +684,7 @@ cuse_server_unref(struct cuse_server *pcs)
mtx_destroy(&pcs->mtx);
+ MPASS(pcs->refs == 0);
free(pcs, M_CUSE);
}