Skip to content

Commit

Permalink
uadk: bugfix CE driver initialization problem
Browse files Browse the repository at this point in the history
When using UADK provider, using the default business type TASK_MIX
will cause driver initialization to fail.
Analysis found that the CE driver will be initialized by fallback,
and NULL will be passed to the input parameter during initialization.
This NULL parameter will cause a segmentation fault during CE driver
initialization.
Therefore, initialization is skipped for NULL parameters in the CE driver.

Signed-off-by: Longfang Liu <[email protected]>
Signed-off-by: Qi Tao <[email protected]>
  • Loading branch information
Longfang Liu authored and Liulongfang committed Aug 12, 2024
1 parent 4beed87 commit fe6638d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions drv/hash_mb/hash_mb.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ static int hash_mb_init(struct wd_alg_driver *drv, void *conf)
struct hash_mb_ctx *priv;
int ret;

/* Fallback init is NULL */
if (!drv || !conf)
return 0;

priv = malloc(sizeof(struct hash_mb_ctx));
if (!priv)
return -WD_ENOMEM;
Expand Down
6 changes: 5 additions & 1 deletion drv/isa_ce_sm3.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,11 @@ static int sm3_ce_drv_init(struct wd_alg_driver *drv, void *conf)
struct wd_ctx_config_internal *config = (struct wd_ctx_config_internal *)conf;
struct sm3_ce_drv_ctx *sctx = (struct sm3_ce_drv_ctx *)drv->priv;

config->epoll_en = false;
/* Fallback init is NULL */
if (!drv || !conf)
return 0;

config->epoll_en = 0;

/* return if already inited */
if (sctx)
Expand Down
4 changes: 4 additions & 0 deletions drv/isa_ce_sm4.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ static int isa_ce_init(struct wd_alg_driver *drv, void *conf)
struct wd_ctx_config_internal *config = conf;
struct sm4_ce_drv_ctx *sctx = drv->priv;

/* Fallback init is NULL */
if (!drv || !conf)
return 0;

config->epoll_en = 0;
memcpy(&sctx->config, config, sizeof(struct wd_ctx_config_internal));

Expand Down

0 comments on commit fe6638d

Please sign in to comment.