Re: [PATCH v1 16/16] dma-mapping: Disallow .map_sg operations from returning zero on error

From
Robin Murphy <robin.murphy@arm.com>
Date
2021-07-16 12:19:36
Also in
linux-arm-kernel, linux-iommu, linux-mips, linux-s390, linuxppc-dev, lkml, sparclinux, xen-devel
Reply to
Christoph Hellwig, 2021-07-16
On 2021-07-16 07:33, Christoph Hellwig wrote:
On Thu, Jul 15, 2021 at 10:45:44AM -0600, Logan Gunthorpe wrote:
quoted
@@ -194,6 +194,8 @@ static int __dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
  	else
  		ents = ops->map_sg(dev, sg, nents, dir, attrs);
  
+	WARN_ON_ONCE(ents == 0);
Turns this into a negative error code while we're at it, just to keep
the callers sane?
Right, by this point returning the 0 would pass through dma_map_sg_attrs() OK, but AFAICS dma_map_sgtable() would now get confused and return success but with sgt->nents = 0. Coercing it to an error code (which dma_map_sg_attrs() would then just change right back) seems sensible for the sake of easy robustness.

Robin.
Thread (28 messages) 28 messages, 6 authors, last reply 2021-07-19
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help