]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: hisilicon: remove unexpected free_netdev
authorPan Bian <bianpan2016@163.com>
Wed, 28 Nov 2018 07:30:24 +0000 (15:30 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Dec 2018 08:24:39 +0000 (09:24 +0100)
[ Upstream commit c758940158bf29fe14e9d0f89d5848f227b48134 ]

The net device ndev is freed via free_netdev when failing to register
the device. The control flow then jumps to the error handling code
block. ndev is used and freed again. Resulting in a use-after-free bug.

Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/hisilicon/hip04_eth.c

index 14374a856d3091a9489e92669c7d93e3e797a115..6127697ede120707fdc92f8d50cc9355487664f3 100644 (file)
@@ -914,10 +914,8 @@ static int hip04_mac_probe(struct platform_device *pdev)
        }
 
        ret = register_netdev(ndev);
-       if (ret) {
-               free_netdev(ndev);
+       if (ret)
                goto alloc_fail;
-       }
 
        return 0;