Add checks for some necessary parameters of dynamically registered drivers.
Signed-off-by: Yang Shen shenyang39@huawei.com --- wd_alg.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/wd_alg.c b/wd_alg.c index 8d88316..3b111c8 100644 --- a/wd_alg.c +++ b/wd_alg.c @@ -139,6 +139,11 @@ int wd_alg_driver_register(struct wd_alg_driver *drv) return -WD_EINVAL; }
+ if (!drv->init || !drv->exit || !drv->send || !drv->recv) { + WD_ERR("invalid: driver's parameter is NULL!\n"); + return -WD_EINVAL; + } + new_alg = calloc(1, sizeof(struct wd_alg_list)); if (!new_alg) { WD_ERR("failed to alloc alg driver memory!\n");