]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ethernet: ucc_geth: fix use-after-free in ucc_geth_remove()
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Fri, 18 Dec 2020 10:55:38 +0000 (11:55 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Jan 2021 19:09:06 +0000 (20:09 +0100)
[ Upstream commit e925e0cd2a705aaacb0b907bb3691fcac3a973a4 ]

ugeth is the netdiv_priv() part of the netdevice. Accessing the memory
pointed to by ugeth (such as done by ucc_geth_memclean() and the two
of_node_puts) after free_netdev() is thus use-after-free.

Fixes: 80a9fad8e89a ("ucc_geth: fix module removal")
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/freescale/ucc_geth.c

index 7c2a9fd4dc1a059c60966e86338ea0faec89e981..c3781334ada2f03e2f12419d05cf3b22cda79e28 100644 (file)
@@ -3939,12 +3939,12 @@ static int ucc_geth_remove(struct platform_device* ofdev)
        struct device_node *np = ofdev->dev.of_node;
 
        unregister_netdev(dev);
-       free_netdev(dev);
        ucc_geth_memclean(ugeth);
        if (of_phy_is_fixed_link(np))
                of_phy_deregister_fixed_link(np);
        of_node_put(ugeth->ug_info->tbi_node);
        of_node_put(ugeth->ug_info->phy_node);
+       free_netdev(dev);
 
        return 0;
 }