[PATCH v3 21/21] dma-mapping: Disallow .map_sg operations from returning zero on error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: linux-kernel@xxxxxxxxxxxxxxx, linux-alpha@xxxxxxxxxxxxxxx, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, linux-ia64@xxxxxxxxxxxxxxx, linux-mips@xxxxxxxxxxxxxxx, linuxppc-dev@xxxxxxxxxxxxxxxx, linux-s390@xxxxxxxxxxxxxxx, sparclinux@xxxxxxxxxxxxxxx, iommu@xxxxxxxxxxxxxxxxxxxxxxxxxx, linux-parisc@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Subject: [PATCH v3 21/21] dma-mapping: Disallow .map_sg operations from returning zero on error
- From: Logan Gunthorpe <logang@xxxxxxxxxxxx>
- Date: Thu, 29 Jul 2021 14:15:39 -0600
- Cc: Christoph Hellwig <hch@xxxxxx>, Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>, Robin Murphy <robin.murphy@xxxxxxx>, Stephen Bates <sbates@xxxxxxxxxxxx>, Martin Oliveira <martin.oliveira@xxxxxxxxxxxxx>, Logan Gunthorpe <logang@xxxxxxxxxxxx>
- In-reply-to: <20210729201539.5602-1-logang@deltatee.com>
- References: <20210729201539.5602-1-logang@deltatee.com>
Now that all the .map_sg operations have been converted to returning
proper error codes, drop the code to handle a zero return value,
add a warning if a zero is returned.
Signed-off-by: Logan Gunthorpe <logang@xxxxxxxxxxxx>
---
kernel/dma/mapping.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c
index 9f0bb56eb9aa..cbcbdc877458 100644
--- a/kernel/dma/mapping.c
+++ b/kernel/dma/mapping.c
@@ -196,8 +196,8 @@ static int __dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
if (ents > 0)
debug_dma_map_sg(dev, sg, nents, ents, dir);
- else if (WARN_ON_ONCE(ents != -EINVAL && ents != -ENOMEM &&
- ents != -EIO && ents != 0))
+ else if (WARN_ON_ONCE((ents != -EINVAL && ents != -ENOMEM &&
+ ents != -EIO) || ents == 0))
return -EIO;
return ents;
@@ -262,9 +262,7 @@ int dma_map_sgtable(struct device *dev, struct sg_table *sgt,
int nents;
nents = __dma_map_sg_attrs(dev, sgt->sgl, sgt->orig_nents, dir, attrs);
- if (nents == 0)
- return -EIO;
- else if (nents < 0)
+ if (nents < 0)
return nents;
sgt->nents = nents;
--
2.20.1
[Index of Archives]
[Linux Kernel]
[Sparc Linux]
[DCCP]
[Linux ARM]
[Yosemite News]
[Linux SCSI]
[Linux x86_64]
[Linux for Ham Radio]