baseband/acc100: fix memory leak

Moved check for undefined device before allocating queue data structure.

Coverity issue: 375803, 375813, 375819, 375827, 375831
Fixes: 060e767293 ("baseband/acc100: add queue configuration")
Cc: stable@dpdk.org

Signed-off-by: Hernan Vargas <hernan.vargas@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
This commit is contained in:
Hernan Vargas 2022-10-20 22:20:36 -07:00 committed by Akhil Goyal
parent 2df5fe2023
commit 36341139e4

View File

@ -663,6 +663,10 @@ acc100_queue_setup(struct rte_bbdev *dev, uint16_t queue_id,
struct acc_queue *q;
int16_t q_idx;
if (d == NULL) {
rte_bbdev_log(ERR, "Undefined device");
return -ENODEV;
}
/* Allocate the queue data structure. */
q = rte_zmalloc_socket(dev->device->driver->name, sizeof(*q),
RTE_CACHE_LINE_SIZE, conf->socket);
@ -670,10 +674,6 @@ acc100_queue_setup(struct rte_bbdev *dev, uint16_t queue_id,
rte_bbdev_log(ERR, "Failed to allocate queue memory");
return -ENOMEM;
}
if (d == NULL) {
rte_bbdev_log(ERR, "Undefined device");
return -ENODEV;
}
q->d = d;
q->ring_addr = RTE_PTR_ADD(d->sw_rings, (d->sw_ring_size * queue_id));