]> git.droids-corp.org - dpdk.git/commitdiff
compress/octeontx: fix null pointer dereference
authorWeiguo Li <liwg06@foxmail.com>
Tue, 25 Jan 2022 14:33:15 +0000 (22:33 +0800)
committerAkhil Goyal <gakhil@marvell.com>
Sat, 12 Feb 2022 09:26:38 +0000 (10:26 +0100)
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 <liwg06@foxmail.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
drivers/compress/octeontx/otx_zip_pmd.c

index 26cdce60a8590b53bbadc813bdc64c20a66aae66..f9b8f7a1ec6ed5d71ef6ebd090039ec4fa264dab 100644 (file)
@@ -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;