Re: 答复: [外部邮件] Re: [PATCH] iommu/dma-iommu: Fix wrong scatterlist length assignment in P2PDMA path
From: Logan Gunthorpe
Date: Tue Jun 02 2026 - 11:58:59 EST
On 2026-06-02 03:48, Li,Rongqing wrote:
> AI report this commit a25e7962db0d79 ("PCI/P2PDMA: Refactor the p2pdma mapping helpers") has other issue, sg->dma_address is uninitialized in case of PCI_P2PDMA_MAP_THRU_HOST_BRIDGE in kernel/dma/direct.c, a possible fix is below:
>
> diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
> index 583c592..4391b79 100644
> --- a/kernel/dma/direct.c
> +++ b/kernel/dma/direct.c
> @@ -476,7 +476,7 @@ int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents,
> * must be mapped with CPU physical address and not PCI
> * bus addresses.
> */
> - break;
> + fallthrough;
> case PCI_P2PDMA_MAP_NONE:
> need_sync = true;
> sg->dma_address = dma_direct_map_phys(dev, sg_phys(sg),
>
Yes, this looks correct as well. Not sure how we missed that.
Reviewed-by: Logan Gunthorpe <logang@xxxxxxxxxxxx>
Thanks,
Logan