net: qcom/emac: fix UAF in emac_remove
authorPavel Skripkin <paskripkin@gmail.com>
Fri, 9 Jul 2021 14:24:18 +0000 (17:24 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Jul 2021 09:12:16 +0000 (11:12 +0200)
commitb1e091331920f8fbfc747dcbd16263fcd71abb2d
tree61c6c4873c6b0b701b1a820c67e8e54272acdc02
parenta600a429809ef0dd248c1368a7c0da53dc30ebc9
net: qcom/emac: fix UAF in emac_remove

commit ad297cd2db8953e2202970e9504cab247b6c7cb4 upstream.

adpt is netdev private data and it cannot be
used after free_netdev() call. Using adpt after free_netdev()
can cause UAF bug. Fix it by moving free_netdev() at the end of the
function.

Fixes: 54e19bc74f33 ("net: qcom/emac: do not use devm on internal phy pdev")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/qualcomm/emac/emac.c