zlib_pmd_qp_setup() publishes the queue pair before completing ring
setup. The cleanup path frees the queue pair but leaves its pointer in
the device slot, so a later release or close can access freed memory.

Clear the published slot when setup fails.

Fixes: 27422fc33cf3 ("compress/zlib: add basic ops")
Cc: [email protected]
Signed-off-by: Xiaojie Zhang <[email protected]>
---
 drivers/compress/zlib/zlib_pmd_ops.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/compress/zlib/zlib_pmd_ops.c 
b/drivers/compress/zlib/zlib_pmd_ops.c
index a530d15..596acc3 100644
--- a/drivers/compress/zlib/zlib_pmd_ops.c
+++ b/drivers/compress/zlib/zlib_pmd_ops.c
@@ -209,6 +209,7 @@ zlib_pmd_qp_setup(struct rte_compressdev *dev, uint16_t 
qp_id,
 qp_setup_cleanup:
        if (qp) {
                rte_free(qp);
+               dev->data->queue_pairs[qp_id] = NULL;
                qp = NULL;
        }
        return -1;
-- 
2.39.5 (Apple Git-154)

Reply via email to