From b072930fb10a0471d69db5de341ea87a0d1561cc Mon Sep 17 00:00:00 2001 From: Weiguo Li Date: Tue, 25 Jan 2022 22:33:15 +0800 Subject: [PATCH] compress/octeontx: fix null pointer dereference Check for memory allocation failure is added to avoid null pointer dereference. Fixes: c378f084d6e3 ("compress/octeontx: add device setup ops") Cc: stable@dpdk.org Signed-off-by: Weiguo Li Acked-by: Akhil Goyal --- drivers/compress/octeontx/otx_zip_pmd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/compress/octeontx/otx_zip_pmd.c b/drivers/compress/octeontx/otx_zip_pmd.c index 26cdce60a8..f9b8f7a1ec 100644 --- a/drivers/compress/octeontx/otx_zip_pmd.c +++ b/drivers/compress/octeontx/otx_zip_pmd.c @@ -391,6 +391,8 @@ zip_pmd_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, } name = rte_malloc(NULL, RTE_COMPRESSDEV_NAME_MAX_LEN, 0); + if (name == NULL) + return (-ENOMEM); snprintf(name, RTE_COMPRESSDEV_NAME_MAX_LEN, "zip_pmd_%u_qp_%u", dev->data->dev_id, qp_id); @@ -398,8 +400,10 @@ zip_pmd_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, /* Allocate the queue pair data structure. */ qp = rte_zmalloc_socket(name, sizeof(*qp), RTE_CACHE_LINE_SIZE, socket_id); - if (qp == NULL) + if (qp == NULL) { + rte_free(name); return (-ENOMEM); + } qp->name = name; -- 2.39.5