diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2026-04-10 08:27:51 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2026-04-10 14:34:48 +0000 |
| commit | 31069fdbdae1027a6f1af7d56d418de4428ac6d9 (patch) | |
| tree | 00bcea9d5cbbcc6ba6aa2461001a67ce032f0047 | |
| parent | 2358492b0347b11178fb594069330820f11ec81f (diff) | |
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
| -rw-r--r-- | sys/kern/kern_event.c | 3 | ||||
| -rw-r--r-- | 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); } |
