public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: linux-sunxi@lists.linux.dev, linux-crypto@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Andre Przywara <andre.przywara@arm.com>,
	Chen-Yu Tsai <wens@csie.org>,
	Corentin Labbe <clabbe.montjoie@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Ovidiu Panait <ovidiu.panait.oss@gmail.com>,
	Samuel Holland <samuel@sholland.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Julia Lawall <julia.lawall@inria.fr>
Subject: [PATCH] crypto: sun8i-ce-hash - Refine exception handling in sun8i_ce_hash_run()
Date: Wed, 9 Apr 2025 13:43:39 +0200	[thread overview]
Message-ID: <3727de04-7993-4b81-80c0-adb40b847307@web.de> (raw)

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 9 Apr 2025 13:26:55 +0200

Two if branches contained duplicate source code.
Thus avoid the specification of repeated error code assignments by using
additional labels instead.

This issue was transformed by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c
index ba13fb75c05d..7d31e190bb6a 100644
--- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c
+++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c
@@ -399,14 +399,14 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq)
 	}
 	if (len > 0) {
 		dev_err(ce->dev, "remaining len %d\n", len);
-		err = -EINVAL;
-		goto err_unmap_src;
+		goto e_inval_src;
 	}
 	addr_res = dma_map_single(ce->dev, result, digestsize, DMA_FROM_DEVICE);
 	cet->t_dst[0].addr = desc_addr_val_le32(ce, addr_res);
 	cet->t_dst[0].len = cpu_to_le32(digestsize / 4);
 	if (dma_mapping_error(ce->dev, addr_res)) {
 		dev_err(ce->dev, "DMA map dest\n");
+e_inval_src:
 		err = -EINVAL;
 		goto err_unmap_src;
 	}
@@ -428,16 +428,15 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq)
 		j = hash_pad(bf, 2 * bs, j, byte_count, false, bs);
 		break;
 	}
-	if (!j) {
-		err = -EINVAL;
-		goto err_unmap_result;
-	}
+	if (!j)
+		goto e_inval_result;

 	addr_pad = dma_map_single(ce->dev, buf, j * 4, DMA_TO_DEVICE);
 	cet->t_src[i].addr = desc_addr_val_le32(ce, addr_pad);
 	cet->t_src[i].len = cpu_to_le32(j);
 	if (dma_mapping_error(ce->dev, addr_pad)) {
 		dev_err(ce->dev, "DMA error on padding SG\n");
+e_inval_result:
 		err = -EINVAL;
 		goto err_unmap_result;
 	}
--
2.49.0



             reply	other threads:[~2025-04-09 11:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-09 11:43 Markus Elfring [this message]
2025-04-09 12:36 ` [PATCH] crypto: sun8i-ce-hash - Refine exception handling in sun8i_ce_hash_run() Andre Przywara
2025-04-09 12:46   ` Markus Elfring
2025-04-13  7:45     ` Julian Calaby
2025-04-13  8:20       ` Markus Elfring
2025-04-10  6:42   ` [PATCH] " Jernej Škrabec
2025-04-10  9:51     ` Markus Elfring

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=3727de04-7993-4b81-80c0-adb40b847307@web.de \
    --to=markus.elfring@web.de \
    --cc=andre.przywara@arm.com \
    --cc=clabbe.montjoie@gmail.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=jernej.skrabec@gmail.com \
    --cc=julia.lawall@inria.fr \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=ovidiu.panait.oss@gmail.com \
    --cc=samuel@sholland.org \
    --cc=wens@csie.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