Skip to content

Commit

Permalink
net: fix cpu_max_bits_warn() usage in netif_attrmask_next{,_and}
Browse files Browse the repository at this point in the history
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 <kuba@kernel.org>
Signed-off-by: Yury Norov <yury.norov@gmail.com>
  • Loading branch information
YuryNorov committed Oct 1, 2022
1 parent 944c417 commit 854701b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -3643,9 +3643,8 @@ static inline bool netif_attr_test_online(unsigned long j,
static inline unsigned int netif_attrmask_next(int n, const unsigned long *srcp,
unsigned int nr_bits)
{
/* -1 is a legal arg here. */
if (n != -1)
cpu_max_bits_warn(n, nr_bits);
/* n is a prior cpu */
cpu_max_bits_warn(n + 1, nr_bits);

if (srcp)
return find_next_bit(srcp, nr_bits, n + 1);
Expand All @@ -3666,9 +3665,8 @@ static inline int netif_attrmask_next_and(int n, const unsigned long *src1p,
const unsigned long *src2p,
unsigned int nr_bits)
{
/* -1 is a legal arg here. */
if (n != -1)
cpu_max_bits_warn(n, nr_bits);
/* n is a prior cpu */
cpu_max_bits_warn(n + 1, nr_bits);

if (src1p && src2p)
return find_next_and_bit(src1p, src2p, nr_bits, n + 1);
Expand Down

0 comments on commit 854701b

Please sign in to comment.