[v3,5/8] ml/cnxk: fix potential memory leak in xstats
Checks
Commit Message
Local buffer xstats_map is not released, when the xstats name
passed by the user application is not valid. This patch releases
the memory in such cases.
Fixes: 4ff4ab8e1a20 ("ml/cnxk: support extended statistics")
Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
---
drivers/ml/cnxk/cn10k_ml_ops.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
@@ -1128,8 +1128,10 @@ cn10k_ml_dev_xstats_by_name_get(struct rte_ml_dev *dev, const char *name, uint16
}
}
- if (id == PLT_DIM(cn10k_ml_model_xstats_table) * dev_info.max_models)
+ if (id == PLT_DIM(cn10k_ml_model_xstats_table) * dev_info.max_models) {
+ rte_free(xstats_map);
return -EINVAL;
+ }
model_id = id / PLT_DIM(cn10k_ml_model_xstats_table);
type = id % PLT_DIM(cn10k_ml_model_xstats_table);