On Mon, Nov 09, 2026 at 06:04:03PM -0800, Stephen Hemminger wrote:
> rte_cfgfile_section_num_entries() returns -1 on error, which is used
> unchecked as a VLA size. With LTO gcc inlines the library call, sees
> the -1 path and fails with -Wvla-larger-than.
>
> Return error if the entry count is negative.
>
> Fixes: db935d0171dd ("examples/qos_sched: use librte_cfgfile")
> Cc: [email protected]
>
> Signed-off-by: Stephen Hemminger <[email protected]>
> ---
> examples/qos_sched/cfg_file.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/examples/qos_sched/cfg_file.c b/examples/qos_sched/cfg_file.c
> index 3ca06c2ff9..e73d9f7cdd 100644
> --- a/examples/qos_sched/cfg_file.c
> +++ b/examples/qos_sched/cfg_file.c
> @@ -438,6 +438,9 @@ cfg_load_subport(struct rte_cfgfile *cfg)
> }
>
> int n_entries = rte_cfgfile_section_num_entries(cfg,
> sec_name);
> + if (n_entries < 0)
> + return -1;
> +
> struct rte_cfgfile_entry entries[n_entries];
In practice I don't think that error case can occur, since an earlier check
verifies that the section exists. However, the check is harmless and not on
a fast-path.
Acked-by: Bruce Richardson <[email protected]>