Re: is dma_mapping_error() check necessary for dma_alloc_noncoherent()?
Baochen Qiang <[email protected]>
| Newsgroups | org.infradead.lists.ath11k,dev.linux.lists.iommu,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On 8/27/2025 3:31 PM, Christoph Hellwig wrote: > On Tue, Aug 26, 2025 at 05:44:42PM +0800, Baochen Qiang wrote: >> Checking code gives me the impression that I should do dma_mapping_error() check as well. >> And indeed with below diff the warning is gone: >> >> + dma_mapping_error(ab->dev, paddr); >> >> However this does not make sense to me since IMO testing the CPU address is good enough, I >> can not imagine a valid case where DMA alloc/map fails while returning a valid CPU >> address, no? > > Yes, this doesn't make sense. dma_mapping_error exists to provide a > error handling path for dma_map_*, which return the dma address only. > > For the dma_alloc_* interfaces that return a pointer and can signal > with a NULL return it should not be needed and dma-debug needs to > be fixed. > >> If I was right, should we remove invocation to debug_dma_map_page() in dma_alloc_pages()? >> > > That allocation still needs to be tracked, so it can't just be removed > but needs to be changed to record the kind of allocation. Thanks, I will submit a patch to fix this.