diff options
author | Hans Petter Selasky <hselasky@FreeBSD.org> | 2020-05-04 10:10:07 +0000 |
---|---|---|
committer | Hans Petter Selasky <hselasky@FreeBSD.org> | 2020-05-04 10:10:07 +0000 |
commit | 5e6233ccabbf10e575054ae29c737c09fe88a71b (patch) | |
tree | e7c27258aea4ab34b2d85fa49e80d6d8efffbd2a /sys/compat/linuxkpi/common | |
parent | fe4b041a14f8207b0af999a50ddd832df7510d3f (diff) | |
download | src-5e6233ccabbf10e575054ae29c737c09fe88a71b.tar.gz src-5e6233ccabbf10e575054ae29c737c09fe88a71b.zip |
Notes
Diffstat (limited to 'sys/compat/linuxkpi/common')
-rw-r--r-- | sys/compat/linuxkpi/common/include/linux/scatterlist.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/scatterlist.h b/sys/compat/linuxkpi/common/include/linux/scatterlist.h index 155304f26615..a23edfb0b4de 100644 --- a/sys/compat/linuxkpi/common/include/linux/scatterlist.h +++ b/sys/compat/linuxkpi/common/include/linux/scatterlist.h @@ -416,6 +416,8 @@ sg_page_count(struct scatterlist *sg) static inline bool __sg_page_iter_next(struct sg_page_iter *piter) { + unsigned int pgcount; + if (piter->internal.nents == 0) return (0); if (piter->sg == NULL) @@ -424,8 +426,11 @@ __sg_page_iter_next(struct sg_page_iter *piter) piter->sg_pgoffset += piter->internal.pg_advance; piter->internal.pg_advance = 1; - while (piter->sg_pgoffset >= sg_page_count(piter->sg)) { - piter->sg_pgoffset -= sg_page_count(piter->sg); + while (1) { + pgcount = sg_page_count(piter->sg); + if (likely(piter->sg_pgoffset < pgcount)) + break; + piter->sg_pgoffset -= pgcount; piter->sg = sg_next(piter->sg); if (--piter->internal.nents == 0) return (0); |