2017-08-08 13:43:42

by Pan Bian

[permalink] [raw]
Subject: crypto: ccp: use dma_mapping_error to check map error

The return value of dma_map_single() should be checked by
dma_mapping_error(). However, in function ccp_init_dm_workarea(), its
return value is checked against NULL, which could result in failures.

Signed-off-by: Pan Bian <[email protected]>
---
drivers/crypto/ccp/ccp-ops.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c
index c0dfdac..ca83d19 100644
--- a/drivers/crypto/ccp/ccp-ops.c
+++ b/drivers/crypto/ccp/ccp-ops.c
@@ -168,7 +168,7 @@ static int ccp_init_dm_workarea(struct ccp_dm_workarea *wa,

wa->dma.address = dma_map_single(wa->dev, wa->address, len,
dir);
- if (!wa->dma.address)
+ if (dma_mapping_error(wa->dev, wa->dma.address))
return -ENOMEM;

wa->dma.length = len;
--
1.9.1


2017-08-08 15:27:41

by Gary R Hook

[permalink] [raw]
Subject: Re: crypto: ccp: use dma_mapping_error to check map error

On 08/08/2017 08:42 AM, Pan Bian wrote:
> The return value of dma_map_single() should be checked by
> dma_mapping_error(). However, in function ccp_init_dm_workarea(), its
> return value is checked against NULL, which could result in failures.
>
> Signed-off-by: Pan Bian <[email protected]>

Acked-by: Gary R Hook <[email protected]>

> ---
> drivers/crypto/ccp/ccp-ops.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c
> index c0dfdac..ca83d19 100644
> --- a/drivers/crypto/ccp/ccp-ops.c
> +++ b/drivers/crypto/ccp/ccp-ops.c
> @@ -168,7 +168,7 @@ static int ccp_init_dm_workarea(struct ccp_dm_workarea *wa,
>
> wa->dma.address = dma_map_single(wa->dev, wa->address, len,
> dir);
> - if (!wa->dma.address)
> + if (dma_mapping_error(wa->dev, wa->dma.address))
> return -ENOMEM;
>
> wa->dma.length = len;
>

2017-08-17 09:00:36

by Herbert Xu

[permalink] [raw]
Subject: Re: crypto: ccp: use dma_mapping_error to check map error

On Tue, Aug 08, 2017 at 09:42:47PM +0800, Pan Bian wrote:
> The return value of dma_map_single() should be checked by
> dma_mapping_error(). However, in function ccp_init_dm_workarea(), its
> return value is checked against NULL, which could result in failures.
>
> Signed-off-by: Pan Bian <[email protected]>

Patch applied. Thanks.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt