diff mbox series

[net] net: Fix features skip in for_each_netdev_feature()

Message ID 20220504080914.1918-1-tariqt@nvidia.com (mailing list archive)
State Accepted
Commit 85db6352fc8a158a893151baa1716463d34a20d0
Delegated to: Netdev Maintainers
Headers show
Series [net] net: Fix features skip in for_each_netdev_feature() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5854 this patch: 5854
netdev/cc_maintainers fail 1 blamed authors not CCed: hauke.mehrtens@intel.com; 2 maintainers not CCed: shenjian15@huawei.com hauke.mehrtens@intel.com
netdev/build_clang success Errors and warnings before: 1152 this patch: 1152
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 5993 this patch: 5993
netdev/checkpatch warning WARNING: line length of 81 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Tariq Toukan May 4, 2022, 8:09 a.m. UTC
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>
---
 include/linux/netdev_features.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Hi,
Please queue to -stable >= v5.0.

Comments

Jakub Kicinski May 6, 2022, 1:30 a.m. UTC | #1
On Wed, 4 May 2022 11:09:14 +0300 Tariq Toukan wrote:
> 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>
> ---
>  include/linux/netdev_features.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> Hi,
> Please queue to -stable >= v5.0.

You can add the normal Cc: stable tags in networking these days, 
the rules were updated.

But I'll forgo doing that here since your >= 5.0 is incorrect, looks 
like the bad commit got backported to earlier stable branches.
Greg will probably do the right thing based on the Fixes tag, anyway.
patchwork-bot+netdevbpf@kernel.org May 6, 2022, 1:50 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 4 May 2022 11:09:14 +0300 you wrote:
> 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>
> 
> [...]

Here is the summary with links:
  - [net] net: Fix features skip in for_each_netdev_feature()
    https://git.kernel.org/netdev/net/c/85db6352fc8a

You are awesome, thank you!
diff mbox series

Patch

diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
index 2c6b9e416225..7c2d77d75a88 100644
--- a/include/linux/netdev_features.h
+++ b/include/linux/netdev_features.h
@@ -169,7 +169,7 @@  enum {
 #define NETIF_F_HW_HSR_FWD	__NETIF_F(HW_HSR_FWD)
 #define NETIF_F_HW_HSR_DUP	__NETIF_F(HW_HSR_DUP)
 
-/* Finds the next feature with the highest number of the range of start till 0.
+/* Finds the next feature with the highest number of the range of start-1 till 0.
  */
 static inline int find_next_netdev_feature(u64 feature, unsigned long start)
 {
@@ -188,7 +188,7 @@  static inline int find_next_netdev_feature(u64 feature, unsigned long start)
 	for ((bit) = find_next_netdev_feature((mask_addr),		\
 					      NETDEV_FEATURE_COUNT);	\
 	     (bit) >= 0;						\
-	     (bit) = find_next_netdev_feature((mask_addr), (bit) - 1))
+	     (bit) = find_next_netdev_feature((mask_addr), (bit)))
 
 /* Features valid for ethtool to change */
 /* = all defined minus driver/device-class-related */