stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Eric Biggers <ebiggers@google.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Sasha Levin <sashal@kernel.org>,
	linux-crypto@vger.kernel.org
Subject: [PATCH AUTOSEL 5.4 48/49] crypto: xts - simplify error handling in ->create()
Date: Thu, 14 May 2020 14:53:09 -0400	[thread overview]
Message-ID: <20200514185311.20294-48-sashal@kernel.org> (raw)
In-Reply-To: <20200514185311.20294-1-sashal@kernel.org>

From: Eric Biggers <ebiggers@google.com>

[ Upstream commit 732e540953477083082e999ff553622c59cffd5f ]

Simplify the error handling in the XTS template's ->create() function by
taking advantage of crypto_drop_skcipher() now accepting (as a no-op) a
spawn that hasn't been grabbed yet.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 crypto/xts.c | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/crypto/xts.c b/crypto/xts.c
index ab117633d64e7..73c648c373595 100644
--- a/crypto/xts.c
+++ b/crypto/xts.c
@@ -384,15 +384,15 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb)
 
 	err = -EINVAL;
 	if (alg->base.cra_blocksize != XTS_BLOCK_SIZE)
-		goto err_drop_spawn;
+		goto err_free_inst;
 
 	if (crypto_skcipher_alg_ivsize(alg))
-		goto err_drop_spawn;
+		goto err_free_inst;
 
 	err = crypto_inst_setname(skcipher_crypto_instance(inst), "xts",
 				  &alg->base);
 	if (err)
-		goto err_drop_spawn;
+		goto err_free_inst;
 
 	err = -EINVAL;
 	cipher_name = alg->base.cra_name;
@@ -405,20 +405,20 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb)
 
 		len = strlcpy(ctx->name, cipher_name + 4, sizeof(ctx->name));
 		if (len < 2 || len >= sizeof(ctx->name))
-			goto err_drop_spawn;
+			goto err_free_inst;
 
 		if (ctx->name[len - 1] != ')')
-			goto err_drop_spawn;
+			goto err_free_inst;
 
 		ctx->name[len - 1] = 0;
 
 		if (snprintf(inst->alg.base.cra_name, CRYPTO_MAX_ALG_NAME,
 			     "xts(%s)", ctx->name) >= CRYPTO_MAX_ALG_NAME) {
 			err = -ENAMETOOLONG;
-			goto err_drop_spawn;
+			goto err_free_inst;
 		}
 	} else
-		goto err_drop_spawn;
+		goto err_free_inst;
 
 	inst->alg.base.cra_flags = alg->base.cra_flags & CRYPTO_ALG_ASYNC;
 	inst->alg.base.cra_priority = alg->base.cra_priority;
@@ -442,17 +442,11 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb)
 	inst->free = free;
 
 	err = skcipher_register_instance(tmpl, inst);
-	if (err)
-		goto err_drop_spawn;
-
-out:
-	return err;
-
-err_drop_spawn:
-	crypto_drop_skcipher(&ctx->spawn);
+	if (err) {
 err_free_inst:
-	kfree(inst);
-	goto out;
+		free(inst);
+	}
+	return err;
 }
 
 static struct crypto_template crypto_tmpl = {
-- 
2.20.1


  parent reply	other threads:[~2020-05-14 19:05 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-14 18:52 [PATCH AUTOSEL 5.4 01/49] kbuild: avoid concurrency issue in parallel building dtbs and dtbs_check Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 02/49] net: drop_monitor: use IS_REACHABLE() to guard net_dm_hw_report() Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 03/49] Makefile: disallow data races on gcc-10 as well Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 04/49] gcc-common.h: Update for GCC 10 Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 05/49] HID: multitouch: add eGalaxTouch P80H84 support Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 06/49] HID: alps: Add AUI1657 device ID Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 07/49] HID: alps: ALPS_1657 is too specific; use U1_UNICORN_LEGACY instead Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 08/49] phy: tegra: Select USB_COMMON for usb_get_maximum_speed() Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 09/49] scsi: qla2xxx: Fix hang when issuing nvme disconnect-all in NPIV Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 10/49] scsi: qla2xxx: Delete all sessions before unregister local nvme port Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 11/49] configfs: fix config_item refcnt leak in configfs_rmdir() Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 12/49] vhost/vsock: fix packet delivery order to monitoring devices Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 13/49] aquantia: Fix the media type of AQC100 ethernet controller in the driver Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 14/49] net/sonic: Fix a resource leak in an error handling path in 'jazz_sonic_probe()' Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 15/49] most: core: use function subsys_initcall() Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 16/49] component: Silence bind error on -EPROBE_DEFER Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 17/49] net/ena: Fix build warning in ena_xdp_set() Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 18/49] scsi: ibmvscsi: Fix WARN_ON during event pool release Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 19/49] HID: i2c-hid: reset Synaptics SYNA2393 on resume Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 20/49] x86/mm/cpa: Flush direct map alias during cpa Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 21/49] ibmvnic: Skip fatal error reset after passive init Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 22/49] soc: qcom: ipa: IPA endpoints Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 23/49] net: ipa: fix a bug in ipa_endpoint_stop() Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 24/49] net: moxa: Fix a potential double 'free_irq()' Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 25/49] ftrace/selftests: workaround cgroup RT scheduling issues Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 26/49] ftrace/selftest: make unresolved cases cause failure if --fail-unresolved set Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 27/49] x86/apic: Move TSC deadline timer debug printk Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 28/49] gtp: set NLM_F_MULTI flag in gtp_genl_dump_pdp() Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 29/49] virtio-blk: handle block_device_operations callbacks after hot unplug Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 30/49] HID: quirks: Add HID_QUIRK_NO_INIT_REPORTS quirk for Dell K12A keyboard-dock Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 31/49] sun6i: dsi: fix gcc-4.8 Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 32/49] ceph: fix double unlock in handle_cap_export() Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 33/49] stmmac: fix pointer check after utilization in stmmac_interrupt Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 34/49] USB: core: Fix misleading driver bug report Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 35/49] platform/x86: asus-nb-wmi: Do not load on Asus T100TA and T200TA Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 36/49] iommu/amd: Call domain_flush_complete() in update_domain() Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 37/49] drm/amd/display: Prevent dpcd reads with passive dongles Sasha Levin
2020-05-14 18:52 ` [PATCH AUTOSEL 5.4 38/49] KVM: selftests: Fix build for evmcs.h Sasha Levin
2020-05-14 18:53 ` [PATCH AUTOSEL 5.4 39/49] ARM: futex: Address build warning Sasha Levin
2020-05-14 18:53 ` [PATCH AUTOSEL 5.4 40/49] scripts/gdb: repair rb_first() and rb_last() Sasha Levin
2020-05-14 18:53 ` [PATCH AUTOSEL 5.4 41/49] Stop the ad-hoc games with -Wno-maybe-initialized Sasha Levin
2020-05-14 18:53 ` [PATCH AUTOSEL 5.4 42/49] gcc-10: disable 'zero-length-bounds' warning for now Sasha Levin
2020-05-14 18:53 ` [PATCH AUTOSEL 5.4 43/49] gcc-10: disable 'array-bounds' " Sasha Levin
2020-05-14 18:53 ` [PATCH AUTOSEL 5.4 44/49] gcc-10: disable 'stringop-overflow' " Sasha Levin
2020-05-14 18:53 ` [PATCH AUTOSEL 5.4 45/49] gcc-10: disable 'restrict' " Sasha Levin
2020-05-14 18:53 ` [PATCH AUTOSEL 5.4 46/49] gcc-10: mark more functions __init to avoid section mismatch warnings Sasha Levin
2020-05-14 18:53 ` [PATCH AUTOSEL 5.4 47/49] crypto: lrw - simplify error handling in create() Sasha Levin
2020-05-14 18:53 ` Sasha Levin [this message]
2020-05-14 18:53 ` [PATCH AUTOSEL 5.4 49/49] gcc-10: avoid shadowing standard library 'free()' in crypto Sasha Levin

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=20200514185311.20294-48-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=ebiggers@google.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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).