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];
 
                        rte_cfgfile_section_entries(cfg, sec_name, entries, 
n_entries);
-- 
2.53.0

Reply via email to