Skip to content

Commit b272732

Browse files
nifeykuba-moo
authored andcommitted
net: txgbe: fix memory leak in txgbe_probe() error path
When txgbe_sw_init() is called, memory is allocated for wx->rss_key in wx_init_rss_key(). However, in txgbe_probe() function, the subsequent error paths after txgbe_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 txgbe_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: 937d46e ("net: wangxun: add ethtool_ops for channel number") Reported-by: Jiawen Wu <[email protected]> Signed-off-by: Abdun Nihaal <[email protected]> Reviewed-by: Jiawen Wu <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent eb25de1 commit b272732

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/ethernet/wangxun/txgbe/txgbe_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ static int txgbe_probe(struct pci_dev *pdev,
611611
/* setup the private structure */
612612
err = txgbe_sw_init(wx);
613613
if (err)
614-
goto err_free_mac_table;
614+
goto err_pci_release_regions;
615615

616616
/* check if flash load is done after hw power up */
617617
err = wx_check_flash_load(wx, TXGBE_SPI_ILDR_STATUS_PERST);
@@ -769,6 +769,7 @@ static int txgbe_probe(struct pci_dev *pdev,
769769
wx_clear_interrupt_scheme(wx);
770770
wx_control_hw(wx, false);
771771
err_free_mac_table:
772+
kfree(wx->rss_key);
772773
kfree(wx->mac_table);
773774
err_pci_release_regions:
774775
pci_release_selected_regions(pdev,

0 commit comments

Comments
 (0)