git: 31069fdbdae1 - main - kevent: do not check knote lists being empty before removing a knote
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 10 Apr 2026 14:35:02 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=31069fdbdae1027a6f1af7d56d418de4428ac6d9
commit 31069fdbdae1027a6f1af7d56d418de4428ac6d9
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-04-10 08:27:51 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-04-10 14:34:48 +0000
kevent: do not check knote lists being empty before removing a knote
If a knote belongs to the list, there is no reason to check for the list
emptiness. On the other hand, if the knote does not belong to the list,
then checking for emptiness is not enough since there might be a
different knote there.
Reviewed bu: kevans, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D56341
---
sys/kern/kern_event.c | 3 +--
sys/kern/vfs_aio.c | 6 ++----
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index 01731ca46b6b..8c7a0949f024 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -2953,8 +2953,7 @@ knote_drop_detached(struct knote *kn, struct thread *td)
else
list = &kq->kq_knhash[KN_HASH(kn->kn_id, kq->kq_knhashmask)];
- if (!SLIST_EMPTY(list))
- SLIST_REMOVE(list, kn, knote, kn_link);
+ SLIST_REMOVE(list, kn, knote, kn_link);
if (kn->kn_status & KN_QUEUED)
knote_dequeue(kn);
KQ_UNLOCK_FLUX(kq);
diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c
index 2a790237d30e..da0e36fc1ec5 100644
--- a/sys/kern/vfs_aio.c
+++ b/sys/kern/vfs_aio.c
@@ -2668,8 +2668,7 @@ filt_aiodetach(struct knote *kn)
knl = &kn->kn_ptr.p_aio->klist;
knl->kl_lock(knl->kl_lockarg);
- if (!knlist_empty(knl))
- knlist_remove(knl, kn, 1);
+ knlist_remove(knl, kn, 1);
knl->kl_unlock(knl->kl_lockarg);
}
@@ -2718,8 +2717,7 @@ filt_liodetach(struct knote *kn)
knl = &kn->kn_ptr.p_lio->klist;
knl->kl_lock(knl->kl_lockarg);
- if (!knlist_empty(knl))
- knlist_remove(knl, kn, 1);
+ knlist_remove(knl, kn, 1);
knl->kl_unlock(knl->kl_lockarg);
}