]> git.baikalelectronics.ru Git - kernel.git/commit
net: dsa: Fix use after free in dsa_switch_remove()
authorFlorian Fainelli <f.fainelli@gmail.com>
Sun, 3 Nov 2019 03:13:26 +0000 (20:13 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 6 Nov 2019 01:53:58 +0000 (17:53 -0800)
commit6ceffc06656bcf7ec2ebd2b9f2d11c08b62999b5
treea3da3bf333e70412ca42f2bcc1fb58318cc8e2af
parent73fd0d4d1a29d22d265206ab89c9b8c11648d28c
net: dsa: Fix use after free in dsa_switch_remove()

The order in which the ports are deleted from the list and freed and the
call to dsa_switch_remove() is done is reversed, which leads to an
use after free condition. Reverse the two: first tear down the ports and
switch from the fabric, then free the ports associated with that switch
fabric.

Fixes: f80116a87c54 ("net: dsa: allocate ports on touch")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Vivien Didelot <vivien.didelot@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dsa/dsa2.c