octeontx2: Fix several bugs in exception paths
cover octeontx2: Fix several bugs in exception paths
Find several obvious bugs during code review in exception paths. Provide this patchset to fix them. Not tested, just compiled.
Ziyang Xuan (2):
octeontx2-pf: Fix possible memory leak in otx2_probe()
octeontx2-vf: Fix possible memory leak in otx2vf_probe()
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 5 ++++- drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c | 12 +++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 octeontx2-pf: Fix possible memory leak in otx2_probe()
In otx2_probe(), there are several possible memory leak bugs in exception paths as follows:
1. Do not release pf->otx2_wq when excute otx2_init_tc() failed.
2. Do not shutdown tc when excute otx2_register_dl() failed.
3. Do not unregister devlink when initialize SR-IOV failed.
--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +4 -1
@@ -2900,7 +2900,7 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) err =otx2_register_dl (pf);if (err) - goto err_mcam_flow_del; + goto err_register_dl;/* Initialize SR-IOV resources */ err =otx2_sriov_vfcfg_init (pf);
@@ -2919,8 +2919,11 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)return 0 ; err_pf_sriov_init: +otx2_unregister_dl (pf); +err_register_dl:otx2_shutdown_tc (pf); err_mcam_flow_del: +destroy_workqueue (pf->otx2_wq);otx2_mcam_flow_del (pf); err_unreg_netdev:unregister_netdev (netdev);
Signature · 1 line
2.25.1
Re: [PATCH net 1/2] octeontx2-pf: Fix possible memory leak in otx2_probe()
Quoted 27 lines · Ziyang Xuan
In
otx2_probe(), there are several possible memory leak bugs in exception paths as follows:
1. Do not releasepf->otx2_wqwhen excuteotx2_init_tc()failed.
2. Do not shutdown tc when excuteotx2_register_dl()failed.
3. Do not unregister devlink when initialize SR-IOV failed.Fixes 1d4d9e42c240 ("octeontx2-pf: Add tc flower hardware offload on ingress traffic")Fixes 2da489432747 ("octeontx2-pf: devlink params support to set mcam entry count")Signed-off-by Ziyang Xuan <[email protected]>--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +1
-1@@ -2900,7 +2900,7 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) err =otx2_register_dl (pf);if (err) - goto err_mcam_flow_del; + goto err_register_dl;/* Initialize SR-IOV resources */ err =otx2_sriov_vfcfg_init (pf);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 2919
Quoted 1 line
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +0
-0@@ -2919,8 +2919,11 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)return 0 ;
If otx2_dcbnl_set_ops() fails at the end then shouldn't we also call otx2_sriov_vfcfg_cleanup() ?
Quoted 13 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +3
-0err_pf_sriov_init: +otx2_unregister_dl (pf); +err_register_dl:otx2_shutdown_tc (pf); err_mcam_flow_del: +destroy_workqueue (pf->otx2_wq);otx2_mcam_flow_del (pf); err_unreg_netdev:unregister_netdev (netdev);Signature · 1 line
2.25.1
Re: [PATCH net 1/2] octeontx2-pf: Fix possible memory leak in otx2_probe()
Quoted 25 lines · Ziyang Xuan
Quoted 24 lines
In
otx2_probe(), there are several possible memory leak bugs in exception paths as follows:
1. Do not releasepf->otx2_wqwhen excuteotx2_init_tc()failed.
2. Do not shutdown tc when excuteotx2_register_dl()failed.
3. Do not unregister devlink when initialize SR-IOV failed.Fixes 1d4d9e42c240 ("octeontx2-pf: Add tc flower hardware offload on ingress traffic")Fixes 2da489432747 ("octeontx2-pf: devlink params support to set mcam entry count")Signed-off-by Ziyang Xuan <[email protected]>--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +1
-1@@ -2900,7 +2900,7 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) err =otx2_register_dl (pf);if (err) - goto err_mcam_flow_del; + goto err_register_dl;
Quoted 7 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 2919
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +0
-0/* Initialize SR-IOV resources */ err =otx2_sriov_vfcfg_init (pf);@@ -2919,8 +2919,11 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)return 0 ;If
otx2_dcbnl_set_ops()fails at the end then shouldn't we also callotx2_sriov_vfcfg_cleanup()?
I think it does not need. This is the probe process. PF and VF are all not ready to work, so pf->vf_configs[i].link_event_work does not scheduled. And pf->vf_configs memory resource will be freed by devm subsystem if probe failed. There are not memory leak and other problems.
@Sunil Goutham, Please help to confirm.
Thanks.
Quoted 16 lines
Quoted 14 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +3
-0err_pf_sriov_init: +otx2_unregister_dl (pf); +err_register_dl:otx2_shutdown_tc (pf); err_mcam_flow_del: +destroy_workqueue (pf->otx2_wq);otx2_mcam_flow_del (pf); err_unreg_netdev:unregister_netdev (netdev);Signature · 1 line
2.25.1.
Re: [PATCH net 1/2] octeontx2-pf: Fix possible memory leak in otx2_probe()
Quoted 33 lines
Quoted 25 lines · Ziyang Xuan
Quoted 24 lines
In
otx2_probe(), there are several possible memory leak bugs in exception paths as follows:
1. Do not releasepf->otx2_wqwhen excuteotx2_init_tc()failed.
2. Do not shutdown tc when excuteotx2_register_dl()failed.
3. Do not unregister devlink when initialize SR-IOV failed.Fixes 1d4d9e42c240 ("octeontx2-pf: Add tc flower hardware offload on ingress traffic")Fixes 2da489432747 ("octeontx2-pf: devlink params support to set mcam entry count")Signed-off-by Ziyang Xuan <[email protected]>--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +1
-1@@ -2900,7 +2900,7 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) err =otx2_register_dl (pf);if (err) - goto err_mcam_flow_del; + goto err_register_dl;Quoted 7 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 2919
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +0
-0/* Initialize SR-IOV resources */ err =otx2_sriov_vfcfg_init (pf);@@ -2919,8 +2919,11 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)return 0 ;If
otx2_dcbnl_set_ops()fails at the end then shouldn't we also callotx2_sriov_vfcfg_cleanup()?
Quoted 4 lines
I think it does not need. This is the probe process. PF and VF are all not ready to work, so pf->vf_configs[i].link_event_work does not scheduled. And
pf->vf_configsmemory resource will be freed by devm subsystem if probe failed. There are not memory leak and other problems.
Hello Sunil Goutham, Maciej Fijalkowski,
What do you think about my analysis? Look forward to your reply.
Thank you!
Quoted 22 lines
@Sunil Goutham, Please help to confirm.
Thanks.
Quoted 16 lines
Quoted 14 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +3
-0err_pf_sriov_init: +otx2_unregister_dl (pf); +err_register_dl:otx2_shutdown_tc (pf); err_mcam_flow_del: +destroy_workqueue (pf->otx2_wq);otx2_mcam_flow_del (pf); err_unreg_netdev:unregister_netdev (netdev);Signature · 1 line
2.25.1.
.
Geethasowjanya Akula
maintainerRe: [EXT] Re: [PATCH net 1/2] octeontx2-pf: Fix possible memory leak in otx2_probe()
________________________________________
From: Ziyang Xuan (William) <[email protected]>
Sent: Friday, December 2, 2022 7:14 AM
To: Maciej Fijalkowski; [email protected]; Sunil Kovvuri Goutham
Cc: Geethasowjanya Akula; Subbaraya Sundeep Bhatta; Hariprasad Kelam; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Naveen Mamindlapalli; Rakesh Babu Saladi; [email protected]
Subject: [EXT] Re: [PATCH net 1/2] octeontx2-pf: Fix possible memory leak in otx2_probe()
External Email
----------------------------------------------------------------------
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines · Ziyang Xuan
Quoted 27 lines
In
otx2_probe(), there are several possible memory leak bugs in exception paths as follows:
1. Do not releasepf->otx2_wqwhen excuteotx2_init_tc()failed.
2. Do not shutdown tc when excuteotx2_register_dl()failed.
3. Do not unregister devlink when initialize SR-IOV failed.Fixes 1d4d9e42c240 ("octeontx2-pf: Add tc flower hardware offload on ingress traffic")Fixes 2da489432747 ("octeontx2-pf: devlink params support to set mcam entry count")Signed-off-by Ziyang Xuan <[email protected]>--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +1
-1@@ -2900,7 +2900,7 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) err =otx2_register_dl (pf);if (err) - goto err_mcam_flow_del; + goto err_register_dl;/* Initialize SR-IOV resources */ err =otx2_sriov_vfcfg_init (pf);drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 2919
Quoted 1 line
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +0
-0@@ -2919,8 +2919,11 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)return 0 ;If
otx2_dcbnl_set_ops()fails at the end then shouldn't we also callotx2_sriov_vfcfg_cleanup()?
Quoted 7 lines
Quoted 4 lines
I think it does not need. This is the probe process. PF and VF are all not ready to work, so pf->vf_configs[i].link_event_work does not scheduled. And
pf->vf_configsmemory resource will be freed by devm subsystem if probe failed. There are not memory leak and other problems.Hello Sunil Goutham, Maciej Fijalkowski,
What do you think about my analysis? Look forward to your >reply.
otx2_sriov_vfcfg_cleanup() is not required. Since PF probe is failed, link event won't get triggered.
Thanks,
Geetha.
Quoted 24 lines
Thank you!
Quoted 22 lines
@Sunil Goutham, Please help to confirm.
Thanks.
Quoted 14 lines
Quoted 12 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +3
-1err_pf_sriov_init: +otx2_unregister_dl (pf); +err_register_dl:otx2_shutdown_tc (pf); err_mcam_flow_del: +destroy_workqueue (pf->otx2_wq);otx2_mcam_flow_del (pf); err_unreg_netdev:unregister_netdev (netdev); --Quoted 2 lines
2.25.1
Quoted 2 lines
.
.
Re: [EXT] Re: [PATCH net 1/2] octeontx2-pf: Fix possible memory leak in otx2_probe()
Quoted 44 lines
________________________________________
From: Ziyang Xuan (William) <[email protected]>
Sent: Friday, December 2, 2022 7:14 AM
To: Maciej Fijalkowski; [email protected]; Sunil Kovvuri Goutham
Cc: Geethasowjanya Akula; Subbaraya Sundeep Bhatta; Hariprasad Kelam; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Naveen Mamindlapalli; Rakesh Babu Saladi; [email protected]
Subject: [EXT] Re: [PATCH net 1/2] octeontx2-pf: Fix possible memory leak inotx2_probe()External Email
----------------------------------------------------------------------
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines · Ziyang Xuan
Quoted 27 lines
In
otx2_probe(), there are several possible memory leak bugs in exception paths as follows:
1. Do not releasepf->otx2_wqwhen excuteotx2_init_tc()failed.
2. Do not shutdown tc when excuteotx2_register_dl()failed.
3. Do not unregister devlink when initialize SR-IOV failed.Fixes 1d4d9e42c240 ("octeontx2-pf: Add tc flower hardware offload on ingress traffic")Fixes 2da489432747 ("octeontx2-pf: devlink params support to set mcam entry count")Signed-off-by Ziyang Xuan <[email protected]>--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +1
-1@@ -2900,7 +2900,7 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) err =otx2_register_dl (pf);if (err) - goto err_mcam_flow_del; + goto err_register_dl;/* Initialize SR-IOV resources */ err =otx2_sriov_vfcfg_init (pf);drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 2919
Quoted 1 line
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +0
-0@@ -2919,8 +2919,11 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)return 0 ;If
otx2_dcbnl_set_ops()fails at the end then shouldn't we also callotx2_sriov_vfcfg_cleanup()?
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
I think it does not need. This is the probe process. PF and VF are all not ready to work, so pf->vf_configs[i].link_event_work does not scheduled. And
pf->vf_configsmemory resource will be freed by devm subsystem if probe failed. There are not memory leak and other problems.Hello Sunil Goutham, Maciej Fijalkowski,
What do you think about my analysis? Look forward to your >reply.
otx2_sriov_vfcfg_cleanup()is not required. Since PF probe is failed, link event won't get triggered.
Hello Geetha,
If there is not any other question, can you add "Reviewed-by" for my patchset?
Thank you!
Quoted 28 lines
Thanks,
Geetha.Quoted 24 lines
Thank you!
Quoted 22 lines
@Sunil Goutham, Please help to confirm.
Thanks.
Quoted 14 lines
Quoted 12 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +3
-1err_pf_sriov_init: +otx2_unregister_dl (pf); +err_register_dl:otx2_shutdown_tc (pf); err_mcam_flow_del: +destroy_workqueue (pf->otx2_wq);otx2_mcam_flow_del (pf); err_unreg_netdev:unregister_netdev (netdev); --Quoted 2 lines
2.25.1
Quoted 2 lines
.
.
.
Re: [EXT] Re: [PATCH net 1/2] octeontx2-pf: Fix possible memory leak in otx2_probe()
________________________________________
From: Ziyang Xuan (William) <[email protected]>
Sent: Friday, December 2, 2022 2:04 PM
To: Geethasowjanya Akula; Maciej Fijalkowski; [email protected]; Sunil Kovvuri Goutham
Cc: Subbaraya Sundeep Bhatta; Hariprasad Kelam; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Naveen Mamindlapalli; Rakesh Babu Saladi; [email protected]
Subject: Re: [EXT] Re: [PATCH net 1/2] octeontx2-pf: Fix possible memory leak in otx2_probe()
Quoted 81 lines
________________________________________
From: Ziyang Xuan (William) <[email protected]>
Sent: Friday, December 2, 2022 7:14 AM
To: Maciej Fijalkowski; [email protected]; Sunil Kovvuri Goutham
Cc: Geethasowjanya Akula; Subbaraya Sundeep Bhatta; Hariprasad Kelam; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Naveen Mamindlapalli; Rakesh Babu Saladi; [email protected]
Subject: [EXT] Re: [PATCH net 1/2] octeontx2-pf: Fix possible memory leak inotx2_probe()External Email
----------------------------------------------------------------------
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines · Ziyang Xuan
Quoted 27 lines
In
otx2_probe(), there are several possible memory leak bugs in exception paths as follows:
1. Do not releasepf->otx2_wqwhen excuteotx2_init_tc()failed.
2. Do not shutdown tc when excuteotx2_register_dl()failed.
3. Do not unregister devlink when initialize SR-IOV failed.Fixes 1d4d9e42c240 ("octeontx2-pf: Add tc flower hardware offload on ingress traffic")Fixes 2da489432747 ("octeontx2-pf: devlink params support to set mcam entry count")Signed-off-by Ziyang Xuan <[email protected]>--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +1
-1@@ -2900,7 +2900,7 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) err =otx2_register_dl (pf);if (err) - goto err_mcam_flow_del; + goto err_register_dl;/* Initialize SR-IOV resources */ err =otx2_sriov_vfcfg_init (pf);drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 2919
Quoted 1 line
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +0
-0@@ -2919,8 +2919,11 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)return 0 ;If
otx2_dcbnl_set_ops()fails at the end then shouldn't we also callotx2_sriov_vfcfg_cleanup()?Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
I think it does not need. This is the probe process. PF and VF are all not ready to work, so pf->vf_configs[i].link_event_work does not scheduled. And
pf->vf_configsmemory resource will be freed by devm subsystem if probe failed. There are not memory leak and other problems.Hello Sunil Goutham, Maciej Fijalkowski,
What do you think about my analysis? Look forward to your >>reply.
otx2_sriov_vfcfg_cleanup()is not required. Since PF probe is failed, link event won't get triggered.Hello Geetha,
If there is not any other question, can you add "Reviewed-by" >for my patchset?
Thank you!
Quoted 22 lines
Thanks,
Geetha.
Thank you!Quoted 18 lines
Quoted 18 lines
@Sunil Goutham, Please help to confirm.
Thanks.
Quoted 13 lines
err_pf_sriov_init:drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +3
-1+otx2_unregister_dl (pf); +err_register_dl:otx2_shutdown_tc (pf); err_mcam_flow_del: +destroy_workqueue (pf->otx2_wq);otx2_mcam_flow_del (pf); err_unreg_netdev:unregister_netdev (netdev); --2.25.1
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
.
.
.
PATCH 2/2 octeontx2-vf: Fix possible memory leak in otx2vf_probe()
In reply to Ziyang XuanIn 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.
--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +9 -3
@@ -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:
Signature · 1 line
2.25.1