From: Vanshika Shukla <[email protected]>

In fm_prev_cleanup(), the port_handle was not closed before being
overwritten on each iteration, causing a resource leak. Add a null
check and close the existing handle before opening a new one.

Fixes: e498f3b51f38 ("net/dpaa: improve port cleanup")
Cc: [email protected]

Signed-off-by: Vanshika Shukla <[email protected]>
---
 drivers/net/dpaa/dpaa_flow.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/dpaa/dpaa_flow.c b/drivers/net/dpaa/dpaa_flow.c
index 417b9b6fbb..f21950f64d 100644
--- a/drivers/net/dpaa/dpaa_flow.c
+++ b/drivers/net/dpaa/dpaa_flow.c
@@ -81,6 +81,10 @@ static void fm_prev_cleanup(void)
                devid = fm_model.device_order[i];
                /* FM Port Open */
                fm_model.fm_port_params[devid].h_fm = fm_info.fman_handle;
+               if (dpaa_intf.port_handle) {
+                       fm_port_close(dpaa_intf.port_handle);
+                       dpaa_intf.port_handle = NULL;
+               }
                dpaa_intf.port_handle =
                                fm_port_open(&fm_model.fm_port_params[devid]);
                dpaa_intf.scheme_handle[0] = create_device(fm_info.pcd_handle,
-- 
2.43.0

Reply via email to