Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: Fix features skip in for_each_netdev_feature()

The find_next_netdev_feature() macro gets the "remaining length",
not bit index.
Passing "bit - 1" for the following iteration is wrong as it skips
the adjacent bit. Pass "bit" instead.

Fixes: 3b89ea9c5902 ("net: Fix for_each_netdev_feature on Big endian")
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Gal Pressman <gal@nvidia.com>
Link: https://lore.kernel.org/r/20220504080914.1918-1-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Tariq Toukan and committed by
Jakub Kicinski
85db6352 690447a2

+2 -2
+2 -2
include/linux/netdev_features.h
··· 169 169 #define NETIF_F_HW_HSR_FWD __NETIF_F(HW_HSR_FWD) 170 170 #define NETIF_F_HW_HSR_DUP __NETIF_F(HW_HSR_DUP) 171 171 172 - /* Finds the next feature with the highest number of the range of start till 0. 172 + /* Finds the next feature with the highest number of the range of start-1 till 0. 173 173 */ 174 174 static inline int find_next_netdev_feature(u64 feature, unsigned long start) 175 175 { ··· 188 188 for ((bit) = find_next_netdev_feature((mask_addr), \ 189 189 NETDEV_FEATURE_COUNT); \ 190 190 (bit) >= 0; \ 191 - (bit) = find_next_netdev_feature((mask_addr), (bit) - 1)) 191 + (bit) = find_next_netdev_feature((mask_addr), (bit))) 192 192 193 193 /* Features valid for ethtool to change */ 194 194 /* = all defined minus driver/device-class-related */