realtek: dsa: Build check size of drop counter names
authorSven Eckelmann <[email protected]>
Mon, 24 Nov 2025 07:54:30 +0000 (08:54 +0100)
committerRobert Marko <[email protected]>
Mon, 24 Nov 2025 16:43:03 +0000 (17:43 +0100)
commit4dab2a94057513b8a013ff2fd90f213c3e6c6ed0
treea9b31777769eb7910055aa5e1b80726c024897e3
parentabb7bbb64ab4ef77045f4c142693623e5e21eb32
realtek: dsa: Build check size of drop counter names

The commit 1cfd45ae0bad ("realtek: Add debugfs support for RTL9300") caused
previously an out of bounds access on the array holding the names of drop
counters (and incorrect names in the output) fur RTL839x because of a
missing comma. To avoid such situation in the future, calculate the size of
the array during compilation. And to ensure that this count matches the
actual number of counters in HW, compare this number during compile time
with the expected value.

Suggested-by: Hauke Mehrtens <[email protected]>
Signed-off-by: Sven Eckelmann <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/20905
Signed-off-by: Robert Marko <[email protected]>
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/debugfs.c