[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v1 16/16] dma-mapping: Disallow .map_sg operations from returning zero on error
 
- To: Christoph Hellwig <hch@xxxxxx>, Logan Gunthorpe <logang@xxxxxxxxxxxx>
 
- From: Robin Murphy <robin.murphy@xxxxxxx>
 
- Date: Fri, 16 Jul 2021 13:19:23 +0100
 
- Cc: linux-s390@xxxxxxxxxxxxxxx, linux-ia64@xxxxxxxxxxxxxxx, linux-parisc@xxxxxxxxxxxxxxx, Martin Oliveira <martin.oliveira@xxxxxxxxxxxxx>, linux-mips@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, iommu@xxxxxxxxxxxxxxxxxxxxxxxxxx, linux-alpha@xxxxxxxxxxxxxxx, sparclinux@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, Stephen Bates <sbates@xxxxxxxxxxxx>, linuxppc-dev@xxxxxxxxxxxxxxxx, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
 
- Delivery-date: Fri, 16 Jul 2021 12:19:38 +0000
 
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
 
 
 
On 2021-07-16 07:33, Christoph Hellwig wrote:
 
On Thu, Jul 15, 2021 at 10:45:44AM -0600, Logan Gunthorpe wrote:
 
@@ -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.
 
 
    
     |