Fix NULL dereference after rte_realloc and add extra NULL checks.
Fix few memory leak with kvargs.
Coverity issue: 345023, 345022, 345009, 345011, 345026, 344997, 344990
Fixes:
ffa4ec0b6063 ("event/octeontx2: allow adapters to resize inflight buffers")
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
prev_xaq_pool = dev->xaq_pool;
dev->xaq_pool = NULL;
- sso_xaq_allocate(dev);
+ rc = sso_xaq_allocate(dev);
+ if (rc < 0) {
+ otx2_err("Failed to alloc xaq pool %d", rc);
+ rte_mempool_free(prev_xaq_pool);
+ return rc;
+ }
rc = sso_ggrp_alloc_xaq(dev);
if (rc < 0) {
otx2_err("Failed to alloc xaq to ggrp %d", rc);
uint8_t *val = (uint8_t *)&queue_qos;
struct otx2_sso_evdev *dev = opaque;
char *tok = strtok(value, "-");
+ struct otx2_sso_qos *old_ptr;
if (!strlen(value))
return;
}
dev->qos_queue_cnt++;
+ old_ptr = dev->qos_parse_data;
dev->qos_parse_data = rte_realloc(dev->qos_parse_data,
sizeof(struct otx2_sso_qos) *
dev->qos_queue_cnt, 0);
+ if (dev->qos_parse_data == NULL) {
+ dev->qos_parse_data = old_ptr;
+ dev->qos_queue_cnt--;
+ return;
+ }
dev->qos_parse_data[dev->qos_queue_cnt - 1] = queue_qos;
}
else if (*s == ']')
end = s;
- if (start < end && *start) {
+ if (start && start < end) {
*end = 0;
parse_queue_param(start + 1, opaque);
s = end;
{
struct otx2_eth_rxq *rxq = data;
int i, match = false;
+ uint64_t *old_ptr;
for (i = 0; i < dev->rx_adptr_pool_cnt; i++) {
if ((uint64_t)rxq->pool == dev->rx_adptr_pools[i])
if (!match) {
dev->rx_adptr_pool_cnt++;
+ old_ptr = dev->rx_adptr_pools;
dev->rx_adptr_pools = rte_realloc(dev->rx_adptr_pools,
sizeof(uint64_t) *
dev->rx_adptr_pool_cnt
, 0);
+ if (dev->rx_adptr_pools == NULL) {
+ dev->adptr_xae_cnt += rxq->pool->size;
+ dev->rx_adptr_pools = old_ptr;
+ dev->rx_adptr_pool_cnt--;
+ return;
+ }
dev->rx_adptr_pools[dev->rx_adptr_pool_cnt - 1] =
(uint64_t)rxq->pool;
struct otx2_tim_evdev *dev = opaque;
struct otx2_tim_ctl ring_ctl = {0};
char *tok = strtok(value, "-");
+ struct otx2_tim_ctl *old_ptr;
uint16_t *val;
val = (uint16_t *)&ring_ctl;
}
dev->ring_ctl_cnt++;
+ old_ptr = dev->ring_ctl_data;
dev->ring_ctl_data = rte_realloc(dev->ring_ctl_data,
- sizeof(struct otx2_tim_ctl), 0);
+ sizeof(struct otx2_tim_ctl) *
+ dev->ring_ctl_cnt, 0);
+ if (dev->ring_ctl_data == NULL) {
+ dev->ring_ctl_data = old_ptr;
+ dev->ring_ctl_cnt--;
+ return;
+ }
+
dev->ring_ctl_data[dev->ring_ctl_cnt - 1] = ring_ctl;
}
else if (*s == ']')
end = s;
- if (start < end && *start) {
+ if (start && start < end) {
*end = 0;
tim_parse_ring_param(start + 1, opaque);
start = end;
&dev->min_ring_cnt);
rte_kvargs_process(kvlist, OTX2_TIM_RING_CTL,
&tim_parse_kvargs_dict, &dev);
+
+ rte_kvargs_free(kvlist);
}
void