app/bbdev: check memory allocation

Return value of a function 'rte_malloc' is dereferenced without
checking, and may result in segmentation fault.

This patch fixed it.

Fixes: 31a7853d1e ("baseband/turbo_sw: support large size code block")
Cc: stable@dpdk.org

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Acked-by: Nicolas Chautru <nicolas.chautru@intel.com>
This commit is contained in:
Min Hu (Connor) 2021-04-22 17:25:05 +08:00 committed by Akhil Goyal
parent 4a8f4f9765
commit bc4c9418ee

View File

@ -957,6 +957,9 @@ init_op_data_objs(struct rte_bbdev_op_data *bufs,
if ((op_type == DATA_INPUT) && large_input) {
/* Allocate a fake overused mbuf */
data = rte_malloc(NULL, seg->length, 0);
TEST_ASSERT_NOT_NULL(data,
"rte malloc failed with %u bytes",
seg->length);
memcpy(data, seg->addr, seg->length);
m_head->buf_addr = data;
m_head->buf_iova = rte_malloc_virt2iova(data);