HomeFreeBSD

linuxkpi: Fix return value of dma_map_sgtable

Description

linuxkpi: Fix return value of dma_map_sgtable

dma_map_sgtable internally uses the dma_map_sg_attrs helper. The problem is
that dma_map_sg_attrs returns the number of entries mapped, whereas
dma_map_sgtable returns nonzero on failure. This leads to dma_map_sgtable
returning non-zero-but-positive values which tricks other areas of the stack
into thinking nents is a valid pointer.

This checks if nents is valid and returns zero if so, updating the nents field
in sgt. This fixes PRIME render offload with nvidia-drm.

Fixes: 9202c95f47c2 ("linuxkpi: Add dma_{un,}map_sgtable")

Details

Provenance
ashafer_badland.ioAuthored on Dec 6 2022, 3:25 PM
manuCommitted on Dec 6 2022, 3:25 PM
Differential Revision
D37611: linuxkpi: Fix return value of dma_map_sgtable
Parents
rGb972e7cbb4f9: bhyve: build SPCR ACPI table
Branches
Unknown
Tags
Unknown