OSDN Git Service

crypto: hisilicon - Bugfixed tfm leak
authorZaibo Xu <xuzaibo@huawei.com>
Sat, 11 Jan 2020 08:58:15 +0000 (16:58 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 16 Jan 2020 07:18:15 +0000 (15:18 +0800)
1.Fixed the bug of software tfm leakage.
2.Update HW error log message.

Signed-off-by: Zaibo Xu <xuzaibo@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/hisilicon/hpre/hpre_crypto.c
drivers/crypto/hisilicon/hpre/hpre_main.c

index 98f037e..d8b0152 100644 (file)
@@ -1043,6 +1043,7 @@ static unsigned int hpre_rsa_max_size(struct crypto_akcipher *tfm)
 static int hpre_rsa_init_tfm(struct crypto_akcipher *tfm)
 {
        struct hpre_ctx *ctx = akcipher_tfm_ctx(tfm);
+       int ret;
 
        ctx->rsa.soft_tfm = crypto_alloc_akcipher("rsa-generic", 0, 0);
        if (IS_ERR(ctx->rsa.soft_tfm)) {
@@ -1050,7 +1051,11 @@ static int hpre_rsa_init_tfm(struct crypto_akcipher *tfm)
                return PTR_ERR(ctx->rsa.soft_tfm);
        }
 
-       return hpre_ctx_init(ctx);
+       ret = hpre_ctx_init(ctx);
+       if (ret)
+               crypto_free_akcipher(ctx->rsa.soft_tfm);
+
+       return ret;
 }
 
 static void hpre_rsa_exit_tfm(struct crypto_akcipher *tfm)
index 711f5d1..753e43d 100644 (file)
@@ -106,18 +106,18 @@ static const char * const hpre_debug_file_name[] = {
 };
 
 static const struct hpre_hw_error hpre_hw_errors[] = {
-       { .int_msk = BIT(0), .msg = "hpre_ecc_1bitt_err" },
-       { .int_msk = BIT(1), .msg = "hpre_ecc_2bit_err" },
-       { .int_msk = BIT(2), .msg = "hpre_data_wr_err" },
-       { .int_msk = BIT(3), .msg = "hpre_data_rd_err" },
-       { .int_msk = BIT(4), .msg = "hpre_bd_rd_err" },
-       { .int_msk = BIT(5), .msg = "hpre_ooo_2bit_ecc_err" },
-       { .int_msk = BIT(6), .msg = "hpre_cltr1_htbt_tm_out_err" },
-       { .int_msk = BIT(7), .msg = "hpre_cltr2_htbt_tm_out_err" },
-       { .int_msk = BIT(8), .msg = "hpre_cltr3_htbt_tm_out_err" },
-       { .int_msk = BIT(9), .msg = "hpre_cltr4_htbt_tm_out_err" },
-       { .int_msk = GENMASK(15, 10), .msg = "hpre_ooo_rdrsp_err" },
-       { .int_msk = GENMASK(21, 16), .msg = "hpre_ooo_wrrsp_err" },
+       { .int_msk = BIT(0), .msg = "core_ecc_1bit_err_int_set" },
+       { .int_msk = BIT(1), .msg = "core_ecc_2bit_err_int_set" },
+       { .int_msk = BIT(2), .msg = "dat_wb_poison_int_set" },
+       { .int_msk = BIT(3), .msg = "dat_rd_poison_int_set" },
+       { .int_msk = BIT(4), .msg = "bd_rd_poison_int_set" },
+       { .int_msk = BIT(5), .msg = "ooo_ecc_2bit_err_int_set" },
+       { .int_msk = BIT(6), .msg = "cluster1_shb_timeout_int_set" },
+       { .int_msk = BIT(7), .msg = "cluster2_shb_timeout_int_set" },
+       { .int_msk = BIT(8), .msg = "cluster3_shb_timeout_int_set" },
+       { .int_msk = BIT(9), .msg = "cluster4_shb_timeout_int_set" },
+       { .int_msk = GENMASK(15, 10), .msg = "ooo_rdrsp_err_int_set" },
+       { .int_msk = GENMASK(21, 16), .msg = "ooo_wrrsp_err_int_set" },
        { /* sentinel */ }
 };