Skip to content

Commit

Permalink
compress/octeontx: fix null pointer dereference
Browse files Browse the repository at this point in the history
[ upstream commit b072930 ]

Check for memory allocation failure is added to avoid null
pointer dereference.

Fixes: c378f08 ("compress/octeontx: add device setup ops")

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
  • Loading branch information
liwg06 authored and bluca committed Feb 17, 2022
1 parent 045d6f7 commit bdd4b32
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/compress/octeontx/otx_zip_pmd.c
Expand Up @@ -392,15 +392,19 @@ 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);

/* 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;

Expand Down

0 comments on commit bdd4b32

Please sign in to comment.