diff mbox series

[1/3] crypto: tcrypt - Fix the wrong position of return value test statement

Message ID 20210812131748.81620-2-tianjia.zhang@linux.alibaba.com
State New
Headers show
Series support test GCM/CCM mode for SM4 | expand

Commit Message

Tianjia Zhang Aug. 12, 2021, 1:17 p.m. UTC
The position of the return value test statement of crypto_aead_setkey()
is wrong, adjust to make it work properly.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
---
 crypto/tcrypt.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Comments

Tianjia Zhang Aug. 13, 2021, 7:38 a.m. UTC | #1
Hi Vitaly,

On 8/12/21 9:59 PM, Vitaly Chikunov wrote:
> Tianjia,

> 

> On Thu, Aug 12, 2021 at 09:17:46PM +0800, Tianjia Zhang wrote:

>> The position of the return value test statement of crypto_aead_setkey()

>> is wrong, adjust to make it work properly.

> 

> This commit message does not explain anything. It's nearly equivalent to

> "fix".

> 


will update in next version.

>>

>> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>

>> ---

>>   crypto/tcrypt.c | 13 ++++++-------

>>   1 file changed, 6 insertions(+), 7 deletions(-)

>>

>> diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c

>> index d73a42fdaa9b..73c97e085baf 100644

>> --- a/crypto/tcrypt.c

>> +++ b/crypto/tcrypt.c

>> @@ -612,6 +612,12 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,

>>   				}

>>   			}

>>   			ret = crypto_aead_setkey(tfm, key, *keysize);

> 

> Perhaps, you would say that return value of crypto_aead_setkey was lost.

> 


Yes, good idea.

>> +			if (ret) {

>> +				pr_err("setkey() failed flags=%x\n",

>> +						crypto_aead_get_flags(tfm));

>> +				goto out;

>> +			}

>> +

>>   			ret = crypto_aead_setauthsize(tfm, authsize);

> 

> But, isn't now return value of crypto_aead_setauthsize is lost?

> 

> Thanks,

> 


Yes, it is needed.

I will move crypto_aead_setauthsize() call out of the loop, only need to 
call it once after load transform.

Best regards,
Tianjia

>>   

>>   			iv_len = crypto_aead_ivsize(tfm);

>> @@ -622,15 +628,8 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,

>>   			printk(KERN_INFO "test %u (%d bit key, %d byte blocks): ",

>>   					i, *keysize * 8, bs);

>>   

>> -

>>   			memset(tvmem[0], 0xff, PAGE_SIZE);

>>   

>> -			if (ret) {

>> -				pr_err("setkey() failed flags=%x\n",

>> -						crypto_aead_get_flags(tfm));

>> -				goto out;

>> -			}

>> -

>>   			sg_init_aead(sg, xbuf, bs + (enc ? 0 : authsize),

>>   				     assoc, aad_size);

>>   

>> -- 

>> 2.19.1.3.ge56e4f7
diff mbox series

Patch

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index d73a42fdaa9b..73c97e085baf 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -612,6 +612,12 @@  static void test_aead_speed(const char *algo, int enc, unsigned int secs,
 				}
 			}
 			ret = crypto_aead_setkey(tfm, key, *keysize);
+			if (ret) {
+				pr_err("setkey() failed flags=%x\n",
+						crypto_aead_get_flags(tfm));
+				goto out;
+			}
+
 			ret = crypto_aead_setauthsize(tfm, authsize);
 
 			iv_len = crypto_aead_ivsize(tfm);
@@ -622,15 +628,8 @@  static void test_aead_speed(const char *algo, int enc, unsigned int secs,
 			printk(KERN_INFO "test %u (%d bit key, %d byte blocks): ",
 					i, *keysize * 8, bs);
 
-
 			memset(tvmem[0], 0xff, PAGE_SIZE);
 
-			if (ret) {
-				pr_err("setkey() failed flags=%x\n",
-						crypto_aead_get_flags(tfm));
-				goto out;
-			}
-
 			sg_init_aead(sg, xbuf, bs + (enc ? 0 : authsize),
 				     assoc, aad_size);