Patchwork crypto: chelsio - Fix an error code in chcr_hash_dma_map()

login
register
mail settings
Submitter Dan Carpenter
Date Nov. 9, 2017, 9:25 p.m.
Message ID <20171109212543.6dpgzvtbhi4574wr@mwanda>
Download mbox | patch
Permalink /patch/10051967/
State Accepted
Delegated to: Herbert Xu
Headers show

Comments

Dan Carpenter - Nov. 9, 2017, 9:25 p.m.
The dma_map_sg() function returns zero on error and positive values on
success.  We want to return -ENOMEM on failure here and zero on success.

Fixes: 2f47d5804311 ("crypto: chelsio - Move DMA un/mapping to chcr from lld cxgb4 driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Herbert Xu - Nov. 29, 2017, 6:31 a.m.
On Fri, Nov 10, 2017 at 12:25:43AM +0300, Dan Carpenter wrote:
> The dma_map_sg() function returns zero on error and positive values on
> success.  We want to return -ENOMEM on failure here and zero on success.
> 
> Fixes: 2f47d5804311 ("crypto: chelsio - Move DMA un/mapping to chcr from lld cxgb4 driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Patch applied.  Thanks.

Patch

diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
index 4eed7171e2ae..38fe59b5c689 100644
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -2414,7 +2414,7 @@  static inline int chcr_hash_dma_map(struct device *dev,
 	error = dma_map_sg(dev, req->src, sg_nents(req->src),
 			   DMA_TO_DEVICE);
 	if (!error)
-		return error;
+		return -ENOMEM;
 	req_ctx->is_sg_map = 1;
 	return 0;
 }