From: Longfang Liu liulongfang@huawei.com
Upstream: Yes DTS:DTS2024061518375 Bugfix or Feature: Bugfix
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 liulongfang@huawei.com --- drv/hash_mb/hash_mb.c | 4 ++++ drv/isa_ce_sm3.c | 6 +++++- drv/isa_ce_sm4.c | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/drv/hash_mb/hash_mb.c b/drv/hash_mb/hash_mb.c index a73c698..e4a9564 100644 --- a/drv/hash_mb/hash_mb.c +++ b/drv/hash_mb/hash_mb.c @@ -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; diff --git a/drv/isa_ce_sm3.c b/drv/isa_ce_sm3.c index 0309861..59f3940 100644 --- a/drv/isa_ce_sm3.c +++ b/drv/isa_ce_sm3.c @@ -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) diff --git a/drv/isa_ce_sm4.c b/drv/isa_ce_sm4.c index 6961471..e937893 100644 --- a/drv/isa_ce_sm4.c +++ b/drv/isa_ce_sm4.c @@ -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));