Skip to contentSkip to conversation

examples/qos_sched: fix build with LTO

PATCH Applied Stephen Hemminger 3 participants 3 messages Nov 10 – Nov 12

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 examples/qos_sched: fix build with LTO

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")
---
 examples/qos_sched/cfg_file.c | 3 +++
 1 file changed, 3 insertions(+)
examples/qos_sched/cfg_file.c +3 -0
index 3ca06c2ff9..e73d9f7cdd 100644
@@ -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);
Signature · 1 line
2.53.0
Acked-by on v1 1/1
#1 lore raw
Quoted 19 lines · Stephen Hemminger

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")
---
 examples/qos_sched/cfg_file.c | 3 +++
 1 file changed, 3 insertions(+)
examples/qos_sched/cfg_file.c +0 -0
index 3ca06c2ff9..e73d9f7cdd 100644

examples/qos_sched/cfg_file.c cfg_load_subport(struct rte_cfgfile *cfg) · line 444

Quoted 7 lines
examples/qos_sched/cfg_file.c +3 -0
@@ -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.

#2 lore raw

10/11/2026 10:05, Bruce Richardson:

Quoted 5 lines · Stephen Hemminger
Quoted 4 lines

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.

Quoted 8 lines
Quoted 6 lines

Return error if the entry count is negative.

Fixes db935d0171dd ("examples/qos_sched: use librte_cfgfile")

Applied, thanks.