Commit 6c412da5 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Jakub Kicinski

sfc: Fix an error handling path in efx_pci_probe()

If an error occurs after the first kzalloc() the corresponding memory
allocation is never freed.

Add the missing kfree() in the error handling path, as already done in the
remove() function.

Fixes: 7e773594 ("sfc: Separate efx_nic memory from net_device memory")
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: default avatarMartin Habets <habetsm.xilinx@gmail.com>
Link: https://lore.kernel.org/r/dc114193121c52c8fa3779e49bdd99d4b41344a9.1667077009.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 363a5328
...@@ -1059,8 +1059,10 @@ static int efx_pci_probe(struct pci_dev *pci_dev, ...@@ -1059,8 +1059,10 @@ static int efx_pci_probe(struct pci_dev *pci_dev,
/* Allocate and initialise a struct net_device */ /* Allocate and initialise a struct net_device */
net_dev = alloc_etherdev_mq(sizeof(probe_data), EFX_MAX_CORE_TX_QUEUES); net_dev = alloc_etherdev_mq(sizeof(probe_data), EFX_MAX_CORE_TX_QUEUES);
if (!net_dev) if (!net_dev) {
return -ENOMEM; rc = -ENOMEM;
goto fail0;
}
probe_ptr = netdev_priv(net_dev); probe_ptr = netdev_priv(net_dev);
*probe_ptr = probe_data; *probe_ptr = probe_data;
efx->net_dev = net_dev; efx->net_dev = net_dev;
...@@ -1132,6 +1134,8 @@ static int efx_pci_probe(struct pci_dev *pci_dev, ...@@ -1132,6 +1134,8 @@ static int efx_pci_probe(struct pci_dev *pci_dev,
WARN_ON(rc > 0); WARN_ON(rc > 0);
netif_dbg(efx, drv, efx->net_dev, "initialisation failed. rc=%d\n", rc); netif_dbg(efx, drv, efx->net_dev, "initialisation failed. rc=%d\n", rc);
free_netdev(net_dev); free_netdev(net_dev);
fail0:
kfree(probe_data);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment