Commit 9cca0c2d authored by Pavel Skripkin's avatar Pavel Skripkin Committed by David S. Miller

net: ethernet: fix potential use-after-free in ec_bhf_remove

static void ec_bhf_remove(struct pci_dev *dev)
{
...
	struct ec_bhf_priv *priv = netdev_priv(net_dev);

	unregister_netdev(net_dev);
	free_netdev(net_dev);

	pci_iounmap(dev, priv->dma_io);
	pci_iounmap(dev, priv->io);
...
}

priv is netdev private data, but it is used
after free_netdev(). It can cause use-after-free when accessing priv
pointer. So, fix it by moving free_netdev() after pci_iounmap()
calls.

Fixes: 6af55ff5 ("Driver for Beckhoff CX5020 EtherCAT master module.")
Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0d1dc9e1
...@@ -576,10 +576,12 @@ static void ec_bhf_remove(struct pci_dev *dev) ...@@ -576,10 +576,12 @@ static void ec_bhf_remove(struct pci_dev *dev)
struct ec_bhf_priv *priv = netdev_priv(net_dev); struct ec_bhf_priv *priv = netdev_priv(net_dev);
unregister_netdev(net_dev); unregister_netdev(net_dev);
free_netdev(net_dev);
pci_iounmap(dev, priv->dma_io); pci_iounmap(dev, priv->dma_io);
pci_iounmap(dev, priv->io); pci_iounmap(dev, priv->io);
free_netdev(net_dev);
pci_release_regions(dev); pci_release_regions(dev);
pci_clear_master(dev); pci_clear_master(dev);
pci_disable_device(dev); pci_disable_device(dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment