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)