From: Pan Bian Date: Wed, 28 Nov 2018 07:30:24 +0000 (+0800) Subject: net: hisilicon: remove unexpected free_netdev X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=c758940158bf29fe14e9d0f89d5848f227b48134;p=openwrt%2Fstaging%2Fblogic.git net: hisilicon: remove unexpected free_netdev 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 Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/hisilicon/hip04_eth.c b/drivers/net/ethernet/hisilicon/hip04_eth.c index be268dcde8fa..f9a4e76c5a8b 100644 --- a/drivers/net/ethernet/hisilicon/hip04_eth.c +++ b/drivers/net/ethernet/hisilicon/hip04_eth.c @@ -915,10 +915,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;