Commit 97feb389 authored by Chenghai Huang's avatar Chenghai Huang Committed by JiangShui
Browse files

crypto: hisilicon/sec2 - optimize the error return process

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8LFYK


CVE: NA

----------------------------------------------------------------------

Added the printf of an error message and optimized the handling
process of ret.

Signed-off-by: default avatarChenghai Huang <huangchenghai2@huawei.com>
Signed-off-by: default avatarJiangShui Yang <yangjiangshui@h-partners.com>
parent 5b53e761
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1149,7 +1149,8 @@ static int sec_aead_setkey(struct crypto_aead *tfm, const u8 *key,
		return 0;
	}

	if (crypto_authenc_extractkeys(&keys, key, keylen))
	ret = crypto_authenc_extractkeys(&keys, key, keylen);
	if (ret)
		goto bad_key;

	ret = sec_aead_aes_set_key(c_ctx, &keys);
@@ -1166,6 +1167,7 @@ static int sec_aead_setkey(struct crypto_aead *tfm, const u8 *key,

	if ((ctx->a_ctx.mac_len & SEC_SQE_LEN_RATE_MASK)  ||
	    (ctx->a_ctx.a_key_len & SEC_SQE_LEN_RATE_MASK)) {
		ret = -EINVAL;
		dev_err(dev, "MAC or AUTH key length error!\n");
		goto bad_key;
	}
@@ -1174,7 +1176,7 @@ static int sec_aead_setkey(struct crypto_aead *tfm, const u8 *key,

bad_key:
	memzero_explicit(&keys, sizeof(struct crypto_authenc_keys));
	return -EINVAL;
	return ret;
}