Fix missing destroyed lock when initialization fails.
Signed-off-by: Wenkai Lin linwenkai6@hisilicon.com Signed-off-by: Weili Qian qianweili@huawei.com --- drv/hisi_qm_udrv.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drv/hisi_qm_udrv.c b/drv/hisi_qm_udrv.c index 9eaf60c..b4e763d 100644 --- a/drv/hisi_qm_udrv.c +++ b/drv/hisi_qm_udrv.c @@ -335,6 +335,14 @@ err_out: return ret; }
+static void hisi_qm_clear_info(struct hisi_qp *qp) +{ + struct hisi_qm_queue_info *q_info = &qp->q_info; + + pthread_spin_destroy(&q_info->lock); + hisi_qm_unset_region(qp->h_ctx, q_info); +} + static int get_free_num(struct hisi_qm_queue_info *q_info) { /* The device should reserve one buffer. */ @@ -374,7 +382,7 @@ handle_t hisi_qm_alloc_qp(struct hisi_qm_priv *config, handle_t ctx) qp->h_sgl_pool = hisi_qm_create_sglpool(HISI_SGL_NUM_IN_BD, HISI_SGE_NUM_IN_SGL); if (!qp->h_sgl_pool) - goto out_qp; + goto free_info;
ret = wd_ctx_start(qp->h_ctx); if (ret) @@ -390,6 +398,8 @@ handle_t hisi_qm_alloc_qp(struct hisi_qm_priv *config, handle_t ctx)
free_pool: hisi_qm_destroy_sglpool(qp->h_sgl_pool); +free_info: + hisi_qm_clear_info(qp); out_qp: free(qp); out: