Skip to content
Commit add2d736 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

net: set initial device refcount to 1



When adding CONFIG_PCPU_DEV_REFCNT, I forgot that the
initial net device refcount was 0.

When CONFIG_PCPU_DEV_REFCNT is not set, this means
the first dev_hold() triggers an illegal refcount
operation (addition on 0)

refcount_t: addition on 0; use-after-free.
WARNING: CPU: 0 PID: 1 at lib/refcount.c:25 refcount_warn_saturate+0x128/0x1a4

Fix is to change initial (and final) refcount to be 1.

Also add a missing kerneldoc piece, as reported by
Stephen Rothwell.

Fixes: 919067cc ("net: add CONFIG_PCPU_DEV_REFCNT")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Reported-by: default avatarGuenter Roeck <groeck@google.com>
Tested-by: default avatarGuenter Roeck <groeck@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0ca99c84
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment