Skip to content

Commit cf96d97

Browse files
Wang Haidavem330
authored andcommitted
net: gemini: Fix missing free_netdev() in error path of gemini_ethernet_port_probe()
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 <[email protected]> Signed-off-by: Wang Hai <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9553b62 commit cf96d97

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/net/ethernet/cortina/gemini.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,7 +2389,7 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
23892389

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

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

25232523
port->netdev = NULL;
2524-
free_netdev(netdev);
25252524
return ret;
25262525
}
25272526

@@ -2530,7 +2529,6 @@ static int gemini_ethernet_port_remove(struct platform_device *pdev)
25302529
struct gemini_ethernet_port *port = platform_get_drvdata(pdev);
25312530

25322531
gemini_port_remove(port);
2533-
free_netdev(port->netdev);
25342532
return 0;
25352533
}
25362534

0 commit comments

Comments
 (0)