git: 6b1e53ad7f65 - main - sglist: use u_int instead of u_short to store sizes
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 17 Nov 2026 17:21:47 UTC
The branch main has been updated by ashafer:
URL: https://cgit.FreeBSD.org/src/commit/?id=6b1e53ad7f65fe0fd71f01462458eada212995b2
commit 6b1e53ad7f65fe0fd71f01462458eada212995b2
Author: Austin Shafer <ashafer@FreeBSD.org>
AuthorDate: 2026-11-04 17:04:59 +0000
Commit: Austin Shafer <ashafer@FreeBSD.org>
CommitDate: 2026-11-17 17:08:33 +0000
sglist: use u_int instead of u_short to store sizes
sglist_alloc accepts an int argument to specify the number of segments
in the sglist. The sglist struct however stores this value in a u_short,
which may wrap in the case of larger sglists. This happens when the
NVIDIA driver performs large allocations, as reported by a user.
This changes updates the use of u_short to a u_int to match the arg
passed into sglist_alloc. The sglist init and save locations are also
updated to no longer use shorts to represent nseg.
Approved by: khng (mentor)
PR: 299611
Sponsored by: NVIDIA
Differential Revision: https://reviews.freebsd.org/D61197
---
sys/kern/subr_sglist.c | 2 +-
sys/sys/sglist.h | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/sys/kern/subr_sglist.c b/sys/kern/subr_sglist.c
index a7162d4d151c..5646fd3bd096 100644
--- a/sys/kern/subr_sglist.c
+++ b/sys/kern/subr_sglist.c
@@ -56,7 +56,7 @@ static MALLOC_DEFINE(M_SGLIST, "sglist", "scatter/gather lists");
* that can occur to the ending segment is that it can be extended.
*/
struct sgsave {
- u_short sg_nseg;
+ u_int sg_nseg;
size_t ss_len;
};
diff --git a/sys/sys/sglist.h b/sys/sys/sglist.h
index 3bbada573772..5f021da622ab 100644
--- a/sys/sys/sglist.h
+++ b/sys/sys/sglist.h
@@ -49,8 +49,8 @@ struct sglist_seg {
struct sglist {
struct sglist_seg *sg_segs;
u_int sg_refs;
- u_short sg_nseg;
- u_short sg_maxseg;
+ u_int sg_nseg;
+ u_int sg_maxseg;
};
struct bio;
@@ -59,7 +59,7 @@ struct thread;
struct uio;
static __inline void
-sglist_init(struct sglist *sg, u_short maxsegs, struct sglist_seg *segs)
+sglist_init(struct sglist *sg, u_int maxsegs, struct sglist_seg *segs)
{
sg->sg_segs = segs;