--- /dev/null
+From 32e76e3757e89f370bf2ac8dba8aeb133071834e Mon Sep 17 00:00:00 2001
+From: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
+Date: Mon, 2 Mar 2026 15:59:14 -0800
+Subject: [PATCH] crypto: tcrypt - clamp num_mb to avoid divide-by-zero
+
+Passing num_mb=0 to the multibuffer speed tests leaves test_mb_aead_cycles()
+and test_mb_acipher_cycles() dividing by (8 * num_mb). With sec=0 (the
+default), the module prints "1 operation in ..." and hits a divide-by-zero
+fault.
+
+Force num_mb to at least 1 during module init and warn the caller so the
+warm-up loop and the final report stay well-defined.
+
+To reproduce:
+sudo modprobe tcrypt mode=600 num_mb=0
+
+Signed-off-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+---
+ crypto/tcrypt.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/crypto/tcrypt.c
++++ b/crypto/tcrypt.c
+@@ -2832,6 +2832,11 @@ static int __init tcrypt_mod_init(void)
+ goto err_free_tv;
+ }
+
++ if (!num_mb) {
++ pr_warn("num_mb must be at least 1; forcing to 1\n");
++ num_mb = 1;
++ }
++
+ err = do_test(alg, type, mask, mode, num_mb);
+
+ if (err) {
--- /dev/null
+From 03170b8f84354f1649a757e57c2130e1de237f5d Mon Sep 17 00:00:00 2001
+From: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
+Date: Mon, 2 Mar 2026 16:06:40 -0800
+Subject: [PATCH] crypto: tcrypt - stop ahash speed tests when setkey fails
+
+The async hash speed path ignores the return code from
+crypto_ahash_setkey(). If the caller picks an unsupported key length,
+the transform keeps whatever key state it already has and the speed test
+still runs, producing misleading numbers, hence bail out of the loop when
+setkey fails.
+
+Signed-off-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+---
+ crypto/tcrypt.c | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+--- a/crypto/tcrypt.c
++++ b/crypto/tcrypt.c
+@@ -911,8 +911,14 @@ static void test_ahash_speed_common(cons
+ break;
+ }
+
+- if (klen)
+- crypto_ahash_setkey(tfm, tvmem[0], klen);
++ if (klen) {
++ ret = crypto_ahash_setkey(tfm, tvmem[0], klen);
++ if (ret) {
++ pr_err("setkey() failed flags=%x: %d\n",
++ crypto_ahash_get_flags(tfm), ret);
++ break;
++ }
++ }
+
+ pr_info("test%3u "
+ "(%5u byte blocks,%5u bytes per update,%4u updates): ",
--- /dev/null
+From 32e76e3757e89f370bf2ac8dba8aeb133071834e Mon Sep 17 00:00:00 2001
+From: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
+Date: Mon, 2 Mar 2026 15:59:14 -0800
+Subject: [PATCH] crypto: tcrypt - clamp num_mb to avoid divide-by-zero
+
+Passing num_mb=0 to the multibuffer speed tests leaves test_mb_aead_cycles()
+and test_mb_acipher_cycles() dividing by (8 * num_mb). With sec=0 (the
+default), the module prints "1 operation in ..." and hits a divide-by-zero
+fault.
+
+Force num_mb to at least 1 during module init and warn the caller so the
+warm-up loop and the final report stay well-defined.
+
+To reproduce:
+sudo modprobe tcrypt mode=600 num_mb=0
+
+Signed-off-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+---
+ crypto/tcrypt.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/crypto/tcrypt.c
++++ b/crypto/tcrypt.c
+@@ -2820,6 +2820,11 @@ static int __init tcrypt_mod_init(void)
+ goto err_free_tv;
+ }
+
++ if (!num_mb) {
++ pr_warn("num_mb must be at least 1; forcing to 1\n");
++ num_mb = 1;
++ }
++
+ err = do_test(alg, type, mask, mode, num_mb);
+
+ if (err) {
--- /dev/null
+From 03170b8f84354f1649a757e57c2130e1de237f5d Mon Sep 17 00:00:00 2001
+From: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
+Date: Mon, 2 Mar 2026 16:06:40 -0800
+Subject: [PATCH] crypto: tcrypt - stop ahash speed tests when setkey fails
+
+The async hash speed path ignores the return code from
+crypto_ahash_setkey(). If the caller picks an unsupported key length,
+the transform keeps whatever key state it already has and the speed test
+still runs, producing misleading numbers, hence bail out of the loop when
+setkey fails.
+
+Signed-off-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+---
+ crypto/tcrypt.c | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+--- a/crypto/tcrypt.c
++++ b/crypto/tcrypt.c
+@@ -911,8 +911,14 @@ static void test_ahash_speed_common(cons
+ break;
+ }
+
+- if (klen)
+- crypto_ahash_setkey(tfm, tvmem[0], klen);
++ if (klen) {
++ ret = crypto_ahash_setkey(tfm, tvmem[0], klen);
++ if (ret) {
++ pr_err("setkey() failed flags=%x: %d\n",
++ crypto_ahash_get_flags(tfm), ret);
++ break;
++ }
++ }
+
+ pr_info("test%3u "
+ "(%5u byte blocks,%5u bytes per update,%4u updates): ",