From 3d84ae9b37c608a045322312a929839042d6b2a9 Mon Sep 17 00:00:00 2001
From: Wenkai Lin <linwenkai6@hisilicon.com>
Date: Sat, 23 Jul 2022 16:50:31 +0800
Subject: [PATCH 164/183] uadk: fix cast pointer problem

The pointer is cast to another pointer in a different type,
fix it with void pointer.

Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
---
 v1/drv/hisi_hpre_udrv.c | 5 +++--
 v1/wd_ecc.c             | 6 +++---
 wd_ecc.c                | 6 +++---
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/v1/drv/hisi_hpre_udrv.c b/v1/drv/hisi_hpre_udrv.c
index 805160e..4a97917 100644
--- a/v1/drv/hisi_hpre_udrv.c
+++ b/v1/drv/hisi_hpre_udrv.c
@@ -1215,8 +1215,9 @@ static int ecc_prepare_verf_in(struct wcrypto_ecc_msg *msg, void **data)
 	return 0;
 }
 
-static int ecc_prepare_dh_gen_in(struct wcrypto_ecc_point *in, void **data)
+static int ecc_prepare_dh_gen_in(void *input, void **data)
 {
+	struct wcrypto_ecc_point *in = input;
 	int ret;
 
 	ret = qm_crypto_bin_to_hpre_bin(in->x.data, (const char *)in->x.data,
@@ -1325,7 +1326,7 @@ static int qm_ecc_prepare_in(struct wcrypto_ecc_msg *msg,
 		hw_msg->bd_rsv2 = 1; /* fall through */
 	case WCRYPTO_ECXDH_GEN_KEY: /* fall through */
 	case WCRYPTO_SM2_KG:
-		ret = ecc_prepare_dh_gen_in((struct wcrypto_ecc_point *)in,
+		ret = ecc_prepare_dh_gen_in((void *)in,
 					    data);
 		break;
 	case WCRYPTO_ECXDH_COMPUTE_KEY:
diff --git a/v1/wd_ecc.c b/v1/wd_ecc.c
index dae5e23..c2a5100 100644
--- a/v1/wd_ecc.c
+++ b/v1/wd_ecc.c
@@ -435,7 +435,7 @@ static struct wcrypto_ecc_in *create_sm2_sign_in(struct wcrypto_ecc_ctx *ctx,
 	}
 
 	in->size = len - sizeof(struct wcrypto_ecc_in);
-	dgst = (struct wd_dtb *)in;
+	dgst = (void *)in;
 	dgst->data = in->data;
 	dgst->dsize = ctx->key_size;
 	dgst->bsize = hsz;
@@ -475,7 +475,7 @@ static struct wcrypto_ecc_in *create_sm2_enc_in(struct wcrypto_ecc_ctx *ctx,
 	}
 
 	in->size = ksz + m_len;
-	k = (struct wd_dtb *)in;
+	k = (void *)in;
 	k->data = in->data;
 	k->dsize = ksz;
 	k->bsize = ksz;
@@ -2017,7 +2017,7 @@ static struct wcrypto_ecc_in *create_sm2_verf_in(struct wcrypto_ecc_ctx *ctx,
 
 	memset(in, 0, len);
 	in->size = len - sizeof(struct wcrypto_ecc_in);
-	dgst = (struct wd_dtb *)in;
+	dgst = (void *)in;
 	dgst->data = in->data;
 	dgst->dsize = ctx->key_size;
 	dgst->bsize = hsz;
diff --git a/wd_ecc.c b/wd_ecc.c
index fed02cb..136e8e2 100644
--- a/wd_ecc.c
+++ b/wd_ecc.c
@@ -445,7 +445,7 @@ static struct wd_ecc_in *create_sm2_sign_in(struct wd_ecc_sess *sess,
 
 	memset(in, 0, len);
 	in->size = len - sizeof(struct wd_ecc_in);
-	dgst = (struct wd_dtb *)in;
+	dgst = (void *)in;
 	dgst->data = in->data;
 	dgst->dsize = ksz;
 	dgst->bsize = ksz;
@@ -485,7 +485,7 @@ static struct wd_ecc_in *create_sm2_enc_in(struct wd_ecc_sess *sess,
 
 	memset(in, 0, len);
 	in->size = ksz + m_len;
-	k = (struct wd_dtb *)in;
+	k = (void *)in;
 	k->data = in->data;
 	k->dsize = ksz;
 	k->bsize = ksz;
@@ -1707,7 +1707,7 @@ static struct wd_ecc_in *create_sm2_verf_in(struct wd_ecc_sess *sess,
 
 	memset(in, 0, len);
 	in->size = len - sizeof(struct wd_ecc_in);
-	dgst = (struct wd_dtb *)in;
+	dgst = (void *)in;
 	dgst->data = in->data;
 	dgst->dsize = sess->key_size;
 	dgst->bsize = hsz;
-- 
2.27.0

