From: Danylo Vodopianov <dvo-...@napatech.com> Issue was fixed with verification in case of the successful memory re-allocation.
Coverity issue: 448959 Fixes: 4033e0539435 ("net/ntnic: add flow meter") Signed-off-by: Danylo Vodopianov <dvo-...@napatech.com> --- .../profile_inline/flow_api_profile_inline.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c index ff8eb502f4..1c7d5cac3e 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c @@ -5523,11 +5523,16 @@ int flow_configure_profile_inline(struct flow_eth_dev *dev, uint8_t caller_id, struct flm_flow_mtr_handle_s *mtr_handle = dev->ndev->flm_mtr_handle; if (mtr_handle->port_stats[caller_id]->shared == 1) { - res = realloc(mtr_handle->port_stats[caller_id]->stats, - port_attr->nb_meters) == NULL - ? -1 - : 0; - mtr_handle->port_stats[caller_id]->size = port_attr->nb_meters; + struct flm_mtr_stat_s *temp_stats = + realloc(mtr_handle->port_stats[caller_id]->stats, + port_attr->nb_meters); + if (temp_stats == NULL) { + res = -1; + } else { + res = 0; + mtr_handle->port_stats[caller_id]->stats = temp_stats; + mtr_handle->port_stats[caller_id]->size = port_attr->nb_meters; + } } else { mtr_handle->port_stats[caller_id] = -- 2.45.0