diff mbox series

[net,2/2] octeontx2-vf: Fix possible memory leak in otx2vf_probe()

Message ID 3828ba413173643c0e04d33f09754eec03c43cfc.1669253985.git.william.xuanziyang@huawei.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series octeontx2: Fix several bugs in exception paths | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 10 of 10 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 33 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Ziyang Xuan (William) Nov. 24, 2022, 1:56 a.m. UTC
In otx2vf_probe(), there are several possible memory leak bugs
in exception paths as follows:
1. Do not release vf->otx2_wq when excute otx2vf_mcam_flow_init() and
   otx2_init_tc() failed.
2. Do not unregister devlink when excute otx2_dcbnl_set_ops() failed.

Fixes: 4b0385bc8e6a ("octeontx2-pf: Add TC feature for VFs")
Fixes: 8e67558177f8 ("octeontx2-pf: PFC config support with DCBx")
Fixes: 3cffaed2136c ("octeontx2-pf: Ntuple filters support for VF netdev")
Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
index 86653bb8e403..f1b47fecd379 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
@@ -684,11 +684,11 @@  static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	err = otx2vf_mcam_flow_init(vf);
 	if (err)
-		goto err_unreg_netdev;
+		goto err_destroy_wq;
 
 	err = otx2_init_tc(vf);
 	if (err)
-		goto err_unreg_netdev;
+		goto err_destroy_wq;
 
 	err = otx2_register_dl(vf);
 	if (err)
@@ -697,13 +697,19 @@  static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 #ifdef CONFIG_DCB
 	err = otx2_dcbnl_set_ops(netdev);
 	if (err)
-		goto err_shutdown_tc;
+		goto err_unreg_dl;
 #endif
 
 	return 0;
 
+#ifdef CONFIG_DCB
+err_unreg_dl:
+	otx2_unregister_dl(vf);
+#endif
 err_shutdown_tc:
 	otx2_shutdown_tc(vf);
+err_destroy_wq:
+	destroy_workqueue(vf->otx2_wq);
 err_unreg_netdev:
 	unregister_netdev(netdev);
 err_ptp_destroy: