2023-11-30 10:43:28

by Antoine Tenart

[permalink] [raw]
Subject: Re: [PATCH] crypto: safexcel - Add error handling for dma_map_sg() calls

Hello Nikita,

Quoting Nikita Zhandarovich (2023-11-29 16:21:45)
>
> diff --git a/drivers/crypto/inside-secure/safexcel_cipher.c b/drivers/crypto/inside-secure/safexcel_cipher.c
> index 272c28b5a088..ca660f31c15f 100644
> --- a/drivers/crypto/inside-secure/safexcel_cipher.c
> +++ b/drivers/crypto/inside-secure/safexcel_cipher.c
> @@ -742,9 +742,9 @@ static int safexcel_send_req(struct crypto_async_request *base, int ring,
> max(totlen_src, totlen_dst));
> return -EINVAL;
> }
> - if (sreq->nr_src > 0)
> - dma_map_sg(priv->dev, src, sreq->nr_src,
> - DMA_BIDIRECTIONAL);
> + if ((sreq->nr_src > 0) &&
> + (!dma_map_sg(priv->dev, src, sreq->nr_src, DMA_BIDIRECTIONAL)))
> + return -ENOMEM;

You can remove one level of parenthesis. Also I'm not sure -ENOMEM is
the right error to return. Looking around it seems people got creative
about that, IMHO -EIO would be best, but not 100% sure.

Same comments for the other chunks.

Thanks,
Antoine