linux/net/dsa
Nikita Yushchenko 7a99cd6e21 net: dsa: fix unbalanced dsa_switch_tree reference counting
_dsa_register_switch() gets a dsa_switch_tree object either via
dsa_get_dst() or via dsa_add_dst(). Former path does not increase kref
in returned object (resulting into caller not owning a reference),
while later path does create a new object (resulting into caller owning
a reference).

The rest of _dsa_register_switch() assumes that it owns a reference, and
calls dsa_put_dst().

This causes a memory breakage if first switch in the tree initialized
successfully, but second failed to initialize. In particular, freed
dsa_swith_tree object is left referenced by switch that was initialized,
and later access to sysfs attributes of that switch cause OOPS.

To fix, need to add kref_get() call to dsa_get_dst().

Fixes: 83c0afaec7 ("net: dsa: Add new binding implementation")
Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-11-28 16:15:45 -05:00
..
dsa2.c net: dsa: fix unbalanced dsa_switch_tree reference counting 2016-11-28 16:15:45 -05:00
dsa_priv.h net-next: dsa: add Qualcomm tag RX/TX handler 2016-09-16 04:31:51 -04:00
dsa.c net: dsa: fix fixed-link-phy device leaks 2016-11-27 20:01:15 -05:00
Kconfig net-next: dsa: add Qualcomm tag RX/TX handler 2016-09-16 04:31:51 -04:00
Makefile net-next: dsa: add Qualcomm tag RX/TX handler 2016-09-16 04:31:51 -04:00
slave.c net: dsa: add port fast ageing 2016-09-23 08:38:50 -04:00
tag_brcm.c net: dsa: Add a ports structure and use it in the switch structure 2016-06-04 14:29:53 -07:00
tag_dsa.c net: dsa: Add a ports structure and use it in the switch structure 2016-06-04 14:29:53 -07:00
tag_edsa.c net: dsa: Add a ports structure and use it in the switch structure 2016-06-04 14:29:53 -07:00
tag_qca.c net-next: dsa: add Qualcomm tag RX/TX handler 2016-09-16 04:31:51 -04:00
tag_trailer.c net: dsa: Add a ports structure and use it in the switch structure 2016-06-04 14:29:53 -07:00