WSL2-Linux-Kernel/net/dsa
Vivien Didelot 9e741045fa net: dsa: fix 'increment on 0' warning
Setting the refcount to 0 when allocating a tree to match the number of
switch devices it holds may cause an 'increment on 0; use-after-free',
if CONFIG_REFCOUNT_FULL is enabled.

To fix this, do not decrement the refcount of a newly allocated tree,
increment it when an already allocated tree is found, and decrement it
after the probing of a switch, as done with the previous behavior.

At the same time, make dsa_tree_get and dsa_tree_put accept a NULL
argument to simplify callers, and return the tree after incrementation,
as most kref users like of_node_get and of_node_put do.

Fixes: 8e5bf9759a ("net: dsa: simplify tree reference counting")
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-11-26 04:23:10 +09:00
..
Kconfig net: dsa: Fix dependencies on bridge 2017-11-14 11:11:45 +09:00
Makefile net: dsa: Support prepended Broadcom tag 2017-11-13 10:34:54 +09:00
dsa.c net: dsa: Support prepended Broadcom tag 2017-11-13 10:34:54 +09:00
dsa2.c net: dsa: fix 'increment on 0' warning 2017-11-26 04:23:10 +09:00
dsa_priv.h net: dsa: Support prepended Broadcom tag 2017-11-13 10:34:54 +09:00
legacy.c net: dsa: Pass a port to get_tag_protocol() 2017-11-13 10:34:54 +09:00
master.c net: dsa: setup and teardown master device 2017-11-09 09:26:49 +09:00
port.c net: dsa: Don't add vlans when vlan filtering is disabled 2017-11-10 14:28:13 +09:00
slave.c net: dsa: Fix SWITCHDEV_ATTR_ID_PORT_PARENT_ID 2017-11-11 19:33:10 +09:00
switch.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2017-11-12 09:17:05 +09:00
tag_brcm.c net: dsa: Support prepended Broadcom tag 2017-11-13 10:34:54 +09:00
tag_dsa.c net: dsa: {e}dsa: set offload_fwd_mark on received packets 2017-11-11 19:33:11 +09:00
tag_edsa.c net: dsa: {e}dsa: set offload_fwd_mark on received packets 2017-11-11 19:33:11 +09:00
tag_ksz.c net: dsa: rename dsa_master_get_slave 2017-10-18 12:24:33 +01:00
tag_lan9303.c net: dsa: lan9303: calculate offload_fwd_mark from tag 2017-11-14 21:47:48 +09:00
tag_mtk.c net: dsa: rename dsa_master_get_slave 2017-10-18 12:24:33 +01:00
tag_qca.c net: dsa: rename dsa_master_get_slave 2017-10-18 12:24:33 +01:00
tag_trailer.c net: dsa: rename dsa_master_get_slave 2017-10-18 12:24:33 +01:00