[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4734941.GXAFRqVoOG@kista>
Date: Thu, 25 Aug 2022 22:36:22 +0200
From: Jernej Škrabec <jernej.skrabec@...il.com>
To: herbert@...dor.apana.org.au, linux-crypto@...r.kernel.org,
Jack Wang <jinpu.wang@...os.com>
Cc: Corentin Labbe <clabbe.montjoie@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Chen-Yu Tsai <wens@...e.org>,
Samuel Holland <samuel@...lland.org>,
Dan Carpenter <dan.carpenter@...cle.com>,
Minghao Chi <chi.minghao@....com.cn>,
Peng Wu <wupeng58@...wei.com>,
Alexey Khoroshilov <khoroshilov@...ras.ru>,
linux-arm-kernel@...ts.infradead.org, linux-sunxi@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 5/6] crypto: allwinner: Fix dma_map_sg error check
Dne četrtek, 25. avgust 2022 ob 09:24:20 CEST je Jack Wang napisal(a):
> dma_map_sg return 0 on error.
>
> Cc: Corentin Labbe <clabbe.montjoie@...il.com>
> Cc: Herbert Xu <herbert@...dor.apana.org.au>
> Cc: "David S. Miller" <davem@...emloft.net>
> Cc: Chen-Yu Tsai <wens@...e.org>
> Cc: Jernej Skrabec <jernej.skrabec@...il.com>
> Cc: Samuel Holland <samuel@...lland.org>
> Cc: Dan Carpenter <dan.carpenter@...cle.com>
> Cc: Minghao Chi <chi.minghao@....com.cn>
> Cc: Peng Wu <wupeng58@...wei.com>
> Cc: Alexey Khoroshilov <khoroshilov@...ras.ru>
> Cc: linux-crypto@...r.kernel.org
> Cc: linux-arm-kernel@...ts.infradead.org
> Cc: linux-sunxi@...ts.linux.dev
> Cc: linux-kernel@...r.kernel.org
> Fixes: 06f751b61329 ("crypto: allwinner - Add sun8i-ce Crypto Engine")
> Fixes: d9b45418a917 ("crypto: sun8i-ss - support hash algorithms")
> Signed-off-by: Jack Wang <jinpu.wang@...os.com>
Acked-by: Jernej Skrabec <jernej.skrabec@...il.com>
Best regards,
Jernej
> ---
> drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c | 6 +++---
> drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 2 +-
> drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c | 4 ++--
> drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c | 2 +-
> 4 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
> b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c index
> 74b4e910a38d..be7f46faef7e 100644
> --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
> +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
> @@ -208,7 +208,7 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine
> *engine, void *async_req
>
> if (areq->src == areq->dst) {
> nr_sgs = dma_map_sg(ce->dev, areq->src, ns,
DMA_BIDIRECTIONAL);
> - if (nr_sgs <= 0 || nr_sgs > MAX_SG) {
> + if (!nr_sgs || nr_sgs > MAX_SG) {
> dev_err(ce->dev, "Invalid sg number %d\n",
nr_sgs);
> err = -EINVAL;
> goto theend_iv;
> @@ -216,13 +216,13 @@ static int sun8i_ce_cipher_prepare(struct
> crypto_engine *engine, void *async_req nr_sgd = nr_sgs;
> } else {
> nr_sgs = dma_map_sg(ce->dev, areq->src, ns,
DMA_TO_DEVICE);
> - if (nr_sgs <= 0 || nr_sgs > MAX_SG) {
> + if (!nr_sgs || nr_sgs > MAX_SG) {
> dev_err(ce->dev, "Invalid sg number %d\n",
nr_sgs);
> err = -EINVAL;
> goto theend_iv;
> }
> nr_sgd = dma_map_sg(ce->dev, areq->dst, nd,
DMA_FROM_DEVICE);
> - if (nr_sgd <= 0 || nr_sgd > MAX_SG) {
> + if (!nr_sgd || nr_sgd > MAX_SG) {
> dev_err(ce->dev, "Invalid sg number %d\n",
nr_sgd);
> err = -EINVAL;
> goto theend_sgs;
> diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c
> b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c index
> 8b5b9b9d04c3..0e6843ec197f 100644
> --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c
> +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c
> @@ -389,7 +389,7 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void
> *breq) cet->t_asym_ctl = 0;
>
> nr_sgs = dma_map_sg(ce->dev, areq->src, ns, DMA_TO_DEVICE);
> - if (nr_sgs <= 0 || nr_sgs > MAX_SG) {
> + if (!nr_sgs || nr_sgs > MAX_SG) {
> dev_err(ce->dev, "Invalid sg number %d\n", nr_sgs);
> err = -EINVAL;
> goto theend;
> diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
> b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c index
> 910d6751644c..fdcc98cdecaa 100644
> --- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
> +++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
> @@ -232,13 +232,13 @@ static int sun8i_ss_cipher(struct skcipher_request
> *areq) nr_sgd = nr_sgs;
> } else {
> nr_sgs = dma_map_sg(ss->dev, areq->src, nsgs,
DMA_TO_DEVICE);
> - if (nr_sgs <= 0 || nr_sgs > 8) {
> + if (!nr_sgs || nr_sgs > 8) {
> dev_err(ss->dev, "Invalid sg number %d\n",
nr_sgs);
> err = -EINVAL;
> goto theend_iv;
> }
> nr_sgd = dma_map_sg(ss->dev, areq->dst, nsgd,
DMA_FROM_DEVICE);
> - if (nr_sgd <= 0 || nr_sgd > 8) {
> + if (!nr_sgd || nr_sgd > 8) {
> dev_err(ss->dev, "Invalid sg number %d\n",
nr_sgd);
> err = -EINVAL;
> goto theend_sgs;
> diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c
> b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c index
> 36a82b22953c..fcb8c41cc957 100644
> --- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c
> +++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c
> @@ -527,7 +527,7 @@ int sun8i_ss_hash_run(struct crypto_engine *engine, void
> *breq) rctx->method = ss->variant->alg_hash[algt->ss_algo_id];
>
> nr_sgs = dma_map_sg(ss->dev, areq->src, sg_nents(areq->src),
> DMA_TO_DEVICE); - if (nr_sgs <= 0 || nr_sgs > MAX_SG) {
> + if (!nr_sgs || nr_sgs > MAX_SG) {
> dev_err(ss->dev, "Invalid sg number %d\n", nr_sgs);
> err = -EINVAL;
> goto theend;
> --
> 2.34.1
Powered by blists - more mailing lists