It is unnecessary to check for NULL pointer before calling free.
Found by nullfree.cocci

Fixes: 1d3f62a0c4f1 ("net/ntnic: add base init and deinit of flow API")
Cc: okl-...@napatech.com

Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
---
 drivers/net/ntnic/nthw/flow_api/flow_api.c                  | 6 ++----
 .../net/ntnic/nthw/flow_api/profile_inline/flm_age_queue.c  | 3 +--
 .../net/ntnic/nthw/flow_api/profile_inline/flm_evt_queue.c  | 3 +--
 .../net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c  | 3 +--
 drivers/net/ntnic/nthw/stat/nthw_stat.c                     | 3 +--
 5 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c 
b/drivers/net/ntnic/nthw/flow_api/flow_api.c
index 5aaf3c2f23..d4993eb58a 100644
--- a/drivers/net/ntnic/nthw/flow_api/flow_api.c
+++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c
@@ -473,8 +473,7 @@ static void done_resource_elements(struct flow_nic_dev 
*ndev, enum res_type_e re
 {
        assert(ndev);
 
-       if (ndev->res[res_type].alloc_bm)
-               free(ndev->res[res_type].alloc_bm);
+       free(ndev->res[res_type].alloc_bm);
 }
 
 static void list_insert_flow_nic(struct flow_nic_dev *ndev)
@@ -653,8 +652,7 @@ static struct flow_eth_dev *flow_get_eth_dev(uint8_t 
adapter_no, uint8_t port_no
        rte_spinlock_unlock(&ndev->mtx);
        rte_spinlock_unlock(&base_mtx);
 
-       if (eth_dev)
-               free(eth_dev);
+       free(eth_dev);
 
 #ifdef FLOW_DEBUG
        ndev->be.iface->set_debug_mode(ndev->be.be_dev, 
FLOW_BACKEND_DEBUG_MODE_NONE);
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_age_queue.c 
b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_age_queue.c
index d916eccec7..c7522516d1 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_age_queue.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_age_queue.c
@@ -40,8 +40,7 @@ void flm_age_queue_free(uint8_t port, uint16_t caller_id)
                age_queue[caller_id] = NULL;
        }
 
-       if (q != NULL)
-               rte_ring_free(q);
+       rte_ring_free(q);
 }
 
 void flm_age_queue_free_all(void)
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_evt_queue.c 
b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_evt_queue.c
index d76c7da568..7c825009ad 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_evt_queue.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_evt_queue.c
@@ -68,8 +68,7 @@ static void flm_inf_sta_queue_free(uint8_t port, uint8_t 
caller)
                break;
        }
 
-       if (q)
-               rte_ring_free(q);
+       rte_ring_free(q);
 }
 
 void flm_inf_sta_queue_free_all(uint8_t caller)
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c 
b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c
index 6e77c28f93..992b1659a8 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c
@@ -31,8 +31,7 @@ void *flm_lrn_queue_create(void)
 
 void flm_lrn_queue_free(void *q)
 {
-       if (q)
-               rte_ring_free(q);
+       rte_ring_free(q);
 }
 
 uint32_t *flm_lrn_queue_get_write_buffer(void *q)
diff --git a/drivers/net/ntnic/nthw/stat/nthw_stat.c 
b/drivers/net/ntnic/nthw/stat/nthw_stat.c
index 078eec5e1f..b0db7b1984 100644
--- a/drivers/net/ntnic/nthw/stat/nthw_stat.c
+++ b/drivers/net/ntnic/nthw/stat/nthw_stat.c
@@ -25,8 +25,7 @@ nthw_stat_t *nthw_stat_new(void)
 
 void nthw_stat_delete(nthw_stat_t *p)
 {
-       if (p)
-               free(p);
+       free(p);
 }
 
 int nthw_stat_init(nthw_stat_t *p, nthw_fpga_t *p_fpga, int n_instance)
-- 
2.45.2

Reply via email to