Skip to content

Commit 854701b

Browse files
committed
net: fix cpu_max_bits_warn() usage in netif_attrmask_next{,_and}
The functions require to be passed with a cpu index prior to one that is the first to start search, so the valid input range is [-1, nr_cpu_ids-1). However, the code checks against [-1, nr_cpu_ids). Acked-by: Jakub Kicinski <[email protected]> Signed-off-by: Yury Norov <[email protected]>
1 parent 944c417 commit 854701b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

include/linux/netdevice.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3643,9 +3643,8 @@ static inline bool netif_attr_test_online(unsigned long j,
36433643
static inline unsigned int netif_attrmask_next(int n, const unsigned long *srcp,
36443644
unsigned int nr_bits)
36453645
{
3646-
/* -1 is a legal arg here. */
3647-
if (n != -1)
3648-
cpu_max_bits_warn(n, nr_bits);
3646+
/* n is a prior cpu */
3647+
cpu_max_bits_warn(n + 1, nr_bits);
36493648

36503649
if (srcp)
36513650
return find_next_bit(srcp, nr_bits, n + 1);
@@ -3666,9 +3665,8 @@ static inline int netif_attrmask_next_and(int n, const unsigned long *src1p,
36663665
const unsigned long *src2p,
36673666
unsigned int nr_bits)
36683667
{
3669-
/* -1 is a legal arg here. */
3670-
if (n != -1)
3671-
cpu_max_bits_warn(n, nr_bits);
3668+
/* n is a prior cpu */
3669+
cpu_max_bits_warn(n + 1, nr_bits);
36723670

36733671
if (src1p && src2p)
36743672
return find_next_and_bit(src1p, src2p, nr_bits, n + 1);

0 commit comments

Comments
 (0)