RE: [PATCH v2 3/7] examples/ip_reassembly: add check before formatting name

Konstantin Ananyev
2025-11-12T14:50:45Z

>
> In theory, lcore and queue could be so large that mbuf pool name
> could overflow. But that can never happen since lcore and queue
> will be in range. Add a check so that static tools know that.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> examples/ip_reassembly/main.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c
> index 17ae76d4ba..25b904dbd4 100644
> --- a/examples/ip_reassembly/main.c
> +++ b/examples/ip_reassembly/main.c
> @@ -884,6 +884,13 @@ setup_queue_tbl(struct rx_queue *rxq, uint32_t lcore,
> uint32_t queue)
>
> nb_mbuf = RTE_MAX(nb_mbuf, (uint32_t)NB_MBUF);
>
> + /* Should never happen but check so that pool name won't be too long. */
> + if (lcore > RTE_MAX_LCORE || queue > RTE_MAX_QUEUES_PER_PORT) {
> + RTE_LOG(ERR, IP_RSMBL, "invalid lcore %u or queue %u",
> + lcore, queue);
> + return -1;
> + }
> +
> snprintf(buf, sizeof(buf), "mbuf_pool_%u_%u", lcore, queue);
>
> rxq->pool = rte_pktmbuf_pool_create(buf, nb_mbuf,
> MEMPOOL_CACHE_SIZE, 0,
> --
Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> 2.51.0