From bdd4b322cf9b8575364d889fb508e3bd4ab6c05c 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 [ upstream commit b072930fb10a0471d69db5de341ea87a0d1561cc ] Check for memory allocation failure is added to avoid null pointer dereference. Fixes: c378f084d6e3 ("compress/octeontx: add device setup ops") 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 bee90fc7cd..ff40968244 100644 --- a/drivers/compress/octeontx/otx_zip_pmd.c +++ b/drivers/compress/octeontx/otx_zip_pmd.c @@ -392,6 +392,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); @@ -399,8 +401,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;