netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: fix napi_disable() logic error
@ 2022-11-17  9:26 Eric Dumazet
  2022-11-18 12:10 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2022-11-17  9:26 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: netdev, eric.dumazet, Eric Dumazet, kernel test robot, Dan Carpenter

Dan reported a new warning after my recent patch:

New smatch warnings:
net/core/dev.c:6409 napi_disable() error: uninitialized symbol 'new'.

Indeed, we must first wait for STATE_SCHED and STATE_NPSVC to be cleared,
to make sure @new variable has been initialized properly.

Fixes: 4ffa1d1c6842 ("net: adopt try_cmpxchg() in napi_{enable|disable}()")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/core/dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index d0fb4af9a12611c7f82798a700205604730e4d10..7627c475d991bfeb7138e0868d423e654d46f036 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6399,9 +6399,9 @@ void napi_disable(struct napi_struct *n)
 
 	val = READ_ONCE(n->state);
 	do {
-		if (val & (NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC)) {
+		while (val & (NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC)) {
 			usleep_range(20, 200);
-			continue;
+			val = READ_ONCE(n->state);
 		}
 
 		new = val | NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC;
-- 
2.38.1.431.g37b22c650d-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] net: fix napi_disable() logic error
  2022-11-17  9:26 [PATCH net-next] net: fix napi_disable() logic error Eric Dumazet
@ 2022-11-18 12:10 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-11-18 12:10 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: davem, kuba, pabeni, netdev, eric.dumazet, lkp, error27

Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Thu, 17 Nov 2022 09:26:41 +0000 you wrote:
> Dan reported a new warning after my recent patch:
> 
> New smatch warnings:
> net/core/dev.c:6409 napi_disable() error: uninitialized symbol 'new'.
> 
> Indeed, we must first wait for STATE_SCHED and STATE_NPSVC to be cleared,
> to make sure @new variable has been initialized properly.
> 
> [...]

Here is the summary with links:
  - [net-next] net: fix napi_disable() logic error
    https://git.kernel.org/netdev/net-next/c/fd896e38e5df

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-18 12:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17  9:26 [PATCH net-next] net: fix napi_disable() logic error Eric Dumazet
2022-11-18 12:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).