Skip to content

Commit

Permalink
net: gemini: Fix missing free_netdev() in error path of gemini_ethern…
Browse files Browse the repository at this point in the history
…et_port_probe()

[ Upstream commit cf96d97 ]

Replace alloc_etherdev_mq with devm_alloc_etherdev_mqs. In this way,
when probe fails, netdev can be freed automatically.

Fixes: 4d5ae32 ("net: ethernet: Add a driver for Gemini gigabit ethernet")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Wang Hai authored and gregkh committed Aug 26, 2020
1 parent f4adc64 commit 2dd00ae
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/net/ethernet/cortina/gemini.c
Original file line number Diff line number Diff line change
Expand Up @@ -2388,7 +2388,7 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)

dev_info(dev, "probe %s ID %d\n", dev_name(dev), id);

netdev = alloc_etherdev_mq(sizeof(*port), TX_QUEUE_NUM);
netdev = devm_alloc_etherdev_mqs(dev, sizeof(*port), TX_QUEUE_NUM, TX_QUEUE_NUM);
if (!netdev) {
dev_err(dev, "Can't allocate ethernet device #%d\n", id);
return -ENOMEM;
Expand Down Expand Up @@ -2520,7 +2520,6 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
}

port->netdev = NULL;
free_netdev(netdev);
return ret;
}

Expand All @@ -2529,7 +2528,6 @@ static int gemini_ethernet_port_remove(struct platform_device *pdev)
struct gemini_ethernet_port *port = platform_get_drvdata(pdev);

gemini_port_remove(port);
free_netdev(port->netdev);
return 0;
}

Expand Down

0 comments on commit 2dd00ae

Please sign in to comment.