From: Vanshika Shukla <[email protected]>

Fix several issues reported by Coverity static analysis:
- Add missing null checks in dpaa_flow.c
- Fix potential resource leak in dpaa_qdma.c

Fixes: e7665de896 ("net/dpaa: fix resource leak")
Cc: [email protected]

Signed-off-by: Vanshika Shukla <[email protected]>
---
 drivers/dma/dpaa/dpaa_qdma.c | 7 ++++++-
 drivers/net/dpaa/dpaa_flow.c | 4 ++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/dpaa/dpaa_qdma.c b/drivers/dma/dpaa/dpaa_qdma.c
index 74e23d2ee5..faf4a7bafe 100644
--- a/drivers/dma/dpaa/dpaa_qdma.c
+++ b/drivers/dma/dpaa/dpaa_qdma.c
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2021-2024 NXP
+ * Copyright 2021-2026 NXP
  */
 
 #include <bus_dpaa_driver.h>
@@ -827,6 +827,11 @@ fsl_qdma_enqueue_desc_sg(struct fsl_qdma_queue *fsl_queue)
                }
        }
 
+       if (num == 0 || num > FSL_QDMA_SG_MAX_ENTRY) {
+               DPAA_QDMA_ERR("Invalid scatter-gather entry count: num=%u", 
num);
+               return -EINVAL;
+       }
+
        ft->desc_ssge[num - 1].final = 1;
        ft->desc_dsge[num - 1].final = 1;
        csgf_src->length = total_len;
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