120 lines
3.6 KiB
Diff
120 lines
3.6 KiB
Diff
|
|
From e002fec5535a971db0c95a27290e61e3ae844a4c Mon Sep 17 00:00:00 2001
|
||
|
|
From: Qi Tao <taoqi10@huawei.com>
|
||
|
|
Date: Fri, 20 Sep 2024 15:13:53 +0800
|
||
|
|
Subject: [PATCH 23/39] uadk: fix the null pointer check error
|
||
|
|
|
||
|
|
After the pointer is used, the null pointer check is performed,
|
||
|
|
which is incorrect.
|
||
|
|
|
||
|
|
Signed-off-by: Qi Tao <taoqi10@huawei.com>
|
||
|
|
---
|
||
|
|
drv/hisi_comp.c | 3 ++-
|
||
|
|
drv/hisi_hpre.c | 3 ++-
|
||
|
|
v1/drv/hisi_zip_udrv.c | 3 ++-
|
||
|
|
wd_zlibwrapper.c | 8 ++++----
|
||
|
|
4 files changed, 10 insertions(+), 7 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/drv/hisi_comp.c b/drv/hisi_comp.c
|
||
|
|
index 2fa5eff..4c8e18b 100644
|
||
|
|
--- a/drv/hisi_comp.c
|
||
|
|
+++ b/drv/hisi_comp.c
|
||
|
|
@@ -836,7 +836,7 @@ out:
|
||
|
|
static void hisi_zip_exit(struct wd_alg_driver *drv)
|
||
|
|
{
|
||
|
|
struct hisi_zip_ctx *priv = (struct hisi_zip_ctx *)drv->priv;
|
||
|
|
- struct wd_ctx_config_internal *config = &priv->config;
|
||
|
|
+ struct wd_ctx_config_internal *config;
|
||
|
|
handle_t h_qp;
|
||
|
|
__u32 i;
|
||
|
|
|
||
|
|
@@ -845,6 +845,7 @@ static void hisi_zip_exit(struct wd_alg_driver *drv)
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
+ config = &priv->config;
|
||
|
|
for (i = 0; i < config->ctx_num; i++) {
|
||
|
|
h_qp = (handle_t)wd_ctx_get_priv(config->ctxs[i].ctx);
|
||
|
|
hisi_qm_free_qp(h_qp);
|
||
|
|
diff --git a/drv/hisi_hpre.c b/drv/hisi_hpre.c
|
||
|
|
index 68a11ae..37bb5ee 100644
|
||
|
|
--- a/drv/hisi_hpre.c
|
||
|
|
+++ b/drv/hisi_hpre.c
|
||
|
|
@@ -584,7 +584,7 @@ static int hpre_ecc_init(struct wd_alg_driver *drv, void *conf)
|
||
|
|
static void hpre_exit(struct wd_alg_driver *drv)
|
||
|
|
{
|
||
|
|
struct hisi_hpre_ctx *priv = (struct hisi_hpre_ctx *)drv->priv;
|
||
|
|
- struct wd_ctx_config_internal *config = &priv->config;
|
||
|
|
+ struct wd_ctx_config_internal *config;
|
||
|
|
handle_t h_qp;
|
||
|
|
__u32 i;
|
||
|
|
|
||
|
|
@@ -593,6 +593,7 @@ static void hpre_exit(struct wd_alg_driver *drv)
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
+ config = &priv->config;
|
||
|
|
for (i = 0; i < config->ctx_num; i++) {
|
||
|
|
h_qp = (handle_t)wd_ctx_get_priv(config->ctxs[i].ctx);
|
||
|
|
hisi_qm_free_qp(h_qp);
|
||
|
|
diff --git a/v1/drv/hisi_zip_udrv.c b/v1/drv/hisi_zip_udrv.c
|
||
|
|
index cc55ef5..01d76a3 100644
|
||
|
|
--- a/v1/drv/hisi_zip_udrv.c
|
||
|
|
+++ b/v1/drv/hisi_zip_udrv.c
|
||
|
|
@@ -254,7 +254,6 @@ int qm_parse_zip_sqe(void *hw_msg, const struct qm_queue_info *info,
|
||
|
|
__u16 i, __u16 usr)
|
||
|
|
{
|
||
|
|
struct wcrypto_comp_msg *recv_msg = info->req_cache[i];
|
||
|
|
- struct wcrypto_comp_tag *tag = (void *)(uintptr_t)recv_msg->udata;
|
||
|
|
struct hisi_zip_sqe *sqe = hw_msg;
|
||
|
|
__u16 ctx_st = sqe->ctx_dw0 & HZ_CTX_ST_MASK;
|
||
|
|
__u16 lstblk = sqe->dw3 & HZ_LSTBLK_MASK;
|
||
|
|
@@ -262,12 +261,14 @@ int qm_parse_zip_sqe(void *hw_msg, const struct qm_queue_info *info,
|
||
|
|
__u32 type = sqe->dw9 & HZ_REQ_TYPE_MASK;
|
||
|
|
uintptr_t phy_in, phy_out, phy_ctxbuf;
|
||
|
|
struct wd_queue *q = info->q;
|
||
|
|
+ struct wcrypto_comp_tag *tag;
|
||
|
|
|
||
|
|
if (unlikely(!recv_msg)) {
|
||
|
|
WD_ERR("info->req_cache is null at index:%hu\n", i);
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
+ tag = (void *)(uintptr_t)recv_msg->udata;
|
||
|
|
if (usr && sqe->tag != usr)
|
||
|
|
return 0;
|
||
|
|
|
||
|
|
diff --git a/wd_zlibwrapper.c b/wd_zlibwrapper.c
|
||
|
|
index 953837a..b3b315f 100644
|
||
|
|
--- a/wd_zlibwrapper.c
|
||
|
|
+++ b/wd_zlibwrapper.c
|
||
|
|
@@ -220,9 +220,6 @@ static int wd_zlib_do_request(z_streamp strm, int flush, enum wd_comp_op_type ty
|
||
|
|
__u32 dst_len = strm->avail_out;
|
||
|
|
int ret;
|
||
|
|
|
||
|
|
- if (unlikely(!strm))
|
||
|
|
- return Z_STREAM_ERROR;
|
||
|
|
-
|
||
|
|
if (unlikely(flush != Z_SYNC_FLUSH && flush != Z_FINISH)) {
|
||
|
|
WD_ERR("invalid: flush is %d!\n", flush);
|
||
|
|
return Z_STREAM_ERROR;
|
||
|
|
@@ -267,12 +264,15 @@ int wd_deflate_init(z_streamp strm, int level, int windowbits)
|
||
|
|
|
||
|
|
int wd_deflate(z_streamp strm, int flush)
|
||
|
|
{
|
||
|
|
+ if (unlikely(!strm))
|
||
|
|
+ return Z_STREAM_ERROR;
|
||
|
|
+
|
||
|
|
return wd_zlib_do_request(strm, flush, WD_DIR_COMPRESS);
|
||
|
|
}
|
||
|
|
|
||
|
|
int wd_deflate_reset(z_streamp strm)
|
||
|
|
{
|
||
|
|
- if (!strm)
|
||
|
|
+ if (unlikely(!strm))
|
||
|
|
return Z_STREAM_ERROR;
|
||
|
|
|
||
|
|
wd_comp_reset_sess((handle_t)strm->reserved);
|
||
|
|
--
|
||
|
|
2.25.1
|
||
|
|
|