Skip to content

Commit

Permalink
net: moxa: fix UAF in moxart_mac_probe
Browse files Browse the repository at this point in the history
commit c78eaee upstream.

In case of netdev registration failure the code path will
jump to init_fail label:

init_fail:
	netdev_err(ndev, "init failed\n");
	moxart_mac_free_memory(ndev);
irq_map_fail:
	free_netdev(ndev);
	return ret;

So, there is no need to call free_netdev() before jumping
to error handling path, since it can cause UAF or double-free
bug.

Fixes: 6c821bd ("net: Add MOXA ART SoCs ethernet driver")
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>
  • Loading branch information
pskrgag authored and gregkh committed Jul 25, 2021
1 parent 88ff9ec commit dbbf5b9
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/net/ethernet/moxa/moxart_ether.c
Expand Up @@ -541,10 +541,8 @@ static int moxart_mac_probe(struct platform_device *pdev)
SET_NETDEV_DEV(ndev, &pdev->dev);

ret = register_netdev(ndev);
if (ret) {
free_netdev(ndev);
if (ret)
goto init_fail;
}

netdev_dbg(ndev, "%s: IRQ=%d address=%pM\n",
__func__, ndev->irq, ndev->dev_addr);
Expand Down

0 comments on commit dbbf5b9

Please sign in to comment.