Skip to content

Commit

Permalink
uadk: fix the null pointer check error
Browse files Browse the repository at this point in the history
After the pointer is used, the null pointer check is performed,
which is incorrect.

Signed-off-by: Qi Tao <[email protected]>
  • Loading branch information
Qi Tao authored and Liulongfang committed Sep 29, 2024
1 parent 5d70926 commit e002fec
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion drv/hisi_comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ static int hisi_zip_init(struct wd_alg_driver *drv, void *conf)
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;

Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion drv/hisi_hpre.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion v1/drv/hisi_zip_udrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,20 +254,21 @@ 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;
__u32 status = sqe->dw3 & HZ_STATUS_MASK;
__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;

Expand Down
8 changes: 4 additions & 4 deletions wd_zlibwrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e002fec

Please sign in to comment.