Skip to content

Commit 88fa800

Browse files
nifeyPaolo Abeni
authored andcommitted
net: ngbe: fix memory leak in ngbe_probe() error path
When ngbe_sw_init() is called, memory is allocated for wx->rss_key in wx_init_rss_key(). However, in ngbe_probe() function, the subsequent error paths after ngbe_sw_init() don't free the rss_key. Fix that by freeing it in error path along with wx->mac_table. Also change the label to which execution jumps when ngbe_sw_init() fails, because otherwise, it could lead to a double free for rss_key, when the mac_table allocation fails in wx_sw_init(). Fixes: 02338c4 ("net: ngbe: Initialize sw info and register netdev") Signed-off-by: Abdun Nihaal <[email protected]> Reviewed-by: Kory Maincent <[email protected]> Reviewed-by: Jiawen Wu <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 65d9119 commit 88fa800

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/ethernet/wangxun/ngbe/ngbe_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ static int ngbe_probe(struct pci_dev *pdev,
625625
/* setup the private structure */
626626
err = ngbe_sw_init(wx);
627627
if (err)
628-
goto err_free_mac_table;
628+
goto err_pci_release_regions;
629629

630630
/* check if flash load is done after hw power up */
631631
err = wx_check_flash_load(wx, NGBE_SPI_ILDR_STATUS_PERST);
@@ -719,6 +719,7 @@ static int ngbe_probe(struct pci_dev *pdev,
719719
err_clear_interrupt_scheme:
720720
wx_clear_interrupt_scheme(wx);
721721
err_free_mac_table:
722+
kfree(wx->rss_key);
722723
kfree(wx->mac_table);
723724
err_pci_release_regions:
724725
pci_release_selected_regions(pdev,

0 commit comments

Comments
 (0)