mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 00:53:34 +02:00
wifi: rtlwifi: fix memory leaks and invalid access at probe error path
Deinitialize at reverse order when probe fails. When init_sw_vars fails, rtl_deinit_core should not be called, specially now that it destroys the rtl_wq workqueue. And call rtl_pci_deinit and deinit_sw_vars, otherwise, memory will be leaked. Remove pci_set_drvdata call as it will already be cleaned up by the core driver code and could lead to memory leaks too. cf. commit8d450935ae("wireless: rtlwifi: remove unnecessary pci_set_drvdata()") and commit3d86b93064("rtlwifi: Fix PCI probe error path orphaned memory"). Fixes:0c8173385e("rtl8192ce: Add new driver") Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20241206173713.3222187-4-cascardo@igalia.com
This commit is contained in:
parent
d8ece6fc36
commit
e7ceefbfd8
|
|
@ -2165,7 +2165,7 @@ int rtl_pci_probe(struct pci_dev *pdev,
|
|||
if (rtlpriv->cfg->ops->init_sw_vars(hw)) {
|
||||
pr_err("Can't init_sw_vars\n");
|
||||
err = -ENODEV;
|
||||
goto fail3;
|
||||
goto fail2;
|
||||
}
|
||||
rtl_init_sw_leds(hw);
|
||||
|
||||
|
|
@ -2183,14 +2183,14 @@ int rtl_pci_probe(struct pci_dev *pdev,
|
|||
err = rtl_pci_init(hw, pdev);
|
||||
if (err) {
|
||||
pr_err("Failed to init PCI\n");
|
||||
goto fail3;
|
||||
goto fail4;
|
||||
}
|
||||
|
||||
err = ieee80211_register_hw(hw);
|
||||
if (err) {
|
||||
pr_err("Can't register mac80211 hw.\n");
|
||||
err = -ENODEV;
|
||||
goto fail3;
|
||||
goto fail5;
|
||||
}
|
||||
rtlpriv->mac80211.mac80211_registered = 1;
|
||||
|
||||
|
|
@ -2213,9 +2213,12 @@ int rtl_pci_probe(struct pci_dev *pdev,
|
|||
set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status);
|
||||
return 0;
|
||||
|
||||
fail3:
|
||||
pci_set_drvdata(pdev, NULL);
|
||||
fail5:
|
||||
rtl_pci_deinit(hw);
|
||||
fail4:
|
||||
rtl_deinit_core(hw);
|
||||
fail3:
|
||||
rtlpriv->cfg->ops->deinit_sw_vars(hw);
|
||||
|
||||
fail2:
|
||||
if (rtlpriv->io.pci_mem_start != 0)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user