HomeFreeBSD

linuxkpi: fix iteration in __sg_alloc_table_from_pages

Description

linuxkpi: fix iteration in __sg_alloc_table_from_pages

Commit 3f686532c9b4 tried to fix an issue with not properly starting
at the first page in the sg list to prevent a panic. This worked but
with the side effect of incrementing "s" during the final iteration
causing it to be NULL since the list had ended.
In cases non-DEBUG kernels this causes a panic with drm-5.15, since
"s" is NULL when we later pass it to sg_mark_end().
This change decouples the iteration sg from the return value so that
it is never incremented past the final page in the chain.

Approved by: re (gjb)
Reviewed by: manu
Differential Revision: https://reviews.freebsd.org/D41574

(cherry picked from commit 09b0401e91a92bcb58ea1873857b42f8211f660f)
(cherry picked from commit 2709483a725e1da2d443d9e391bfaa0f223099be)

Details

Provenance
ashafer_badland.ioAuthored on Sep 6 2023, 2:08 PM
bzCommitted on Oct 10 2023, 2:33 PM
Reviewer
manu
Differential Revision
D41574: linuxkpi: Fix iteration in __sg_alloc_table_from_pages again
Parents
rG41023d85b3bc: netlink: fix accessing freed memory
Branches
Unknown
Tags
Unknown