From: Weiguo Li Date: Tue, 25 Jan 2022 14:33:15 +0000 (+0800) Subject: compress/octeontx: fix null pointer dereference X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b072930fb10a0471d69db5de341ea87a0d1561cc;p=dpdk.git 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 --- 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;