Date: Wed, 22 Apr 2026 12:37:24 +0000 From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 827dccf3ff5c - stable/15 - linuxkpi: Fix an off-by-one error in the kfifo implementation Message-ID: <69e8c104.47fb6.2e7d9faf@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/15 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=827dccf3ff5c48b2f62378a44f58bf287fe99550 commit 827dccf3ff5c48b2f62378a44f58bf287fe99550 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2026-04-15 13:33:04 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2026-04-22 12:37:07 +0000 linuxkpi: Fix an off-by-one error in the kfifo implementation "total" is the number of slots in the array, so wraparound needs to be done when "first" or "last" is greater than or equal to the number of slots. Note that no consumers of the code are currently connected to the kernel build. Reported by: Stanislav Fort <stanislav.fort@aisle.com> Reviewed by: bz, emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D56371 (cherry picked from commit 52d2fc702b85d56b35f8828fe7efca3cde0d25b7) --- sys/compat/linuxkpi/common/include/linux/kfifo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/kfifo.h b/sys/compat/linuxkpi/common/include/linux/kfifo.h index d2f570781661..b9f6ecacd3d1 100644 --- a/sys/compat/linuxkpi/common/include/linux/kfifo.h +++ b/sys/compat/linuxkpi/common/include/linux/kfifo.h @@ -71,7 +71,7 @@ (_kf)->head[(_kf)->last] = (_e); \ (_kf)->count++; \ (_kf)->last++; \ - if ((_kf)->last > (_kf)->total) \ + if ((_kf)->last >= (_kf)->total) \ (_kf)->last = 0; \ _rc = true; \ } \ @@ -89,7 +89,7 @@ *(_e) = (_kf)->head[(_kf)->first]; \ (_kf)->count--; \ (_kf)->first++; \ - if ((_kf)->first > (_kf)->total) \ + if ((_kf)->first >= (_kf)->total) \ (_kf)->first = 0; \ _rc = true; \ } \home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69e8c104.47fb6.2e7d9faf>
