linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Horia Geanta <horia.geanta@nxp.com>
Cc: linuxppc-dev@lists.ozlabs.org, linux-crypto@vger.kernel.org,
	stable@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/2] crypto: talitos - reorder code in talitos_edesc_alloc()
Date: Tue, 8 Jan 2019 10:51:41 +0100	[thread overview]
Message-ID: <cfb285c6-5700-194d-d4b2-9cc8601dbc04@c-s.fr> (raw)
In-Reply-To: <5ed91db5e2976a4c260465c3d027acc9affd2d2b.1545445924.git.christophe.leroy@c-s.fr>



Le 08/01/2019 à 07:56, Christophe Leroy a écrit :
> This patch moves the mapping of IV after the kmalloc(). This
> avoids having to unmap in case kmalloc() fails.
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>

Cc: stable@vger.kernel.org

> ---
>   new in v4
> 
>   drivers/crypto/talitos.c | 25 +++++++------------------
>   1 file changed, 7 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
> index 45e20707cef8..54d80e7edb86 100644
> --- a/drivers/crypto/talitos.c
> +++ b/drivers/crypto/talitos.c
> @@ -1361,23 +1361,18 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
>   	struct talitos_private *priv = dev_get_drvdata(dev);
>   	bool is_sec1 = has_ftr_sec1(priv);
>   	int max_len = is_sec1 ? TALITOS1_MAX_DATA_LEN : TALITOS2_MAX_DATA_LEN;
> -	void *err;
>   
>   	if (cryptlen + authsize > max_len) {
>   		dev_err(dev, "length exceeds h/w max limit\n");
>   		return ERR_PTR(-EINVAL);
>   	}
>   
> -	if (ivsize)
> -		iv_dma = dma_map_single(dev, iv, ivsize, DMA_TO_DEVICE);
> -
>   	if (!dst || dst == src) {
>   		src_len = assoclen + cryptlen + authsize;
>   		src_nents = sg_nents_for_len(src, src_len);
>   		if (src_nents < 0) {
>   			dev_err(dev, "Invalid number of src SG.\n");
> -			err = ERR_PTR(-EINVAL);
> -			goto error_sg;
> +			return ERR_PTR(-EINVAL);
>   		}
>   		src_nents = (src_nents == 1) ? 0 : src_nents;
>   		dst_nents = dst ? src_nents : 0;
> @@ -1387,16 +1382,14 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
>   		src_nents = sg_nents_for_len(src, src_len);
>   		if (src_nents < 0) {
>   			dev_err(dev, "Invalid number of src SG.\n");
> -			err = ERR_PTR(-EINVAL);
> -			goto error_sg;
> +			return ERR_PTR(-EINVAL);
>   		}
>   		src_nents = (src_nents == 1) ? 0 : src_nents;
>   		dst_len = assoclen + cryptlen + (encrypt ? authsize : 0);
>   		dst_nents = sg_nents_for_len(dst, dst_len);
>   		if (dst_nents < 0) {
>   			dev_err(dev, "Invalid number of dst SG.\n");
> -			err = ERR_PTR(-EINVAL);
> -			goto error_sg;
> +			return ERR_PTR(-EINVAL);
>   		}
>   		dst_nents = (dst_nents == 1) ? 0 : dst_nents;
>   	}
> @@ -1425,10 +1418,10 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
>   		alloc_len += sizeof(struct talitos_desc);
>   
>   	edesc = kmalloc(alloc_len, GFP_DMA | flags);
> -	if (!edesc) {
> -		err = ERR_PTR(-ENOMEM);
> -		goto error_sg;
> -	}
> +	if (!edesc)
> +		return ERR_PTR(-ENOMEM);
> +	if (ivsize)
> +		iv_dma = dma_map_single(dev, iv, ivsize, DMA_TO_DEVICE);
>   	memset(&edesc->desc, 0, sizeof(edesc->desc));
>   
>   	edesc->src_nents = src_nents;
> @@ -1445,10 +1438,6 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
>   						     DMA_BIDIRECTIONAL);
>   	}
>   	return edesc;
> -error_sg:
> -	if (iv_dma)
> -		dma_unmap_single(dev, iv_dma, ivsize, DMA_TO_DEVICE);
> -	return err;
>   }
>   
>   static struct talitos_edesc *aead_edesc_alloc(struct aead_request *areq, u8 *iv,
> 

  parent reply	other threads:[~2019-01-08  9:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-08  6:56 [PATCH v4 1/2] crypto: talitos - reorder code in talitos_edesc_alloc() Christophe Leroy
2019-01-08  6:56 ` [PATCH v4 2/2] crypto: talitos - fix ablkcipher for CONFIG_VMAP_STACK Christophe Leroy
2019-01-08  9:48   ` Horia Geanta
2019-01-08  9:47 ` [PATCH v4 1/2] crypto: talitos - reorder code in talitos_edesc_alloc() Horia Geanta
2019-01-08  9:51 ` Christophe Leroy [this message]
2019-01-10 14:05 ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cfb285c6-5700-194d-d4b2-9cc8601dbc04@c-s.fr \
    --to=christophe.leroy@c-s.fr \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=horia.geanta@nxp.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).