* [PATCH 0/3] unnecessary checks for null
@ 2024-11-12 17:38 Stephen Hemminger
2024-11-12 17:38 ` [PATCH 1/3] bus/fslmc: remove unnecessary null check Stephen Hemminger
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Stephen Hemminger @ 2024-11-12 17:38 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Found by running nullfree.cocci on 24.11-rc2
Stephen Hemminger (3):
bus/fslmc: remove unnecessary null check
net/dpaa2: remove unnecessary check for null before rte_free
net/ntnic: remove unnecessary check for null before free
drivers/bus/fslmc/fslmc_vfio.c | 3 +--
drivers/net/dpaa2/dpaa2_ethdev.c | 3 +--
drivers/net/dpaa2/dpaa2_flow.c | 27 +++++++------------
drivers/net/dpaa2/dpaa2_mux.c | 6 ++---
drivers/net/ntnic/nthw/flow_api/flow_api.c | 6 ++---
.../flow_api/profile_inline/flm_age_queue.c | 3 +--
.../flow_api/profile_inline/flm_evt_queue.c | 3 +--
.../flow_api/profile_inline/flm_lrn_queue.c | 3 +--
drivers/net/ntnic/nthw/stat/nthw_stat.c | 3 +--
9 files changed, 19 insertions(+), 38 deletions(-)
--
2.45.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] bus/fslmc: remove unnecessary null check
2024-11-12 17:38 [PATCH 0/3] unnecessary checks for null Stephen Hemminger
@ 2024-11-12 17:38 ` Stephen Hemminger
2024-11-13 5:01 ` Hemant Agrawal
2024-11-12 17:38 ` [PATCH 2/3] net/dpaa2: remove unnecessary check for null before rte_free Stephen Hemminger
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2024-11-12 17:38 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, jun.yang, Hemant Agrawal, Sachin Saxena
No need for check for null before calling free().
Caught by nullfree.cocci script.
Fixes: 57cb02edf122 ("bus/fslmc: enhance MC VFIO multi-process support")
Cc: jun.yang@nxp.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/bus/fslmc/fslmc_vfio.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index c581dcc4e2..7a584b9280 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -557,8 +557,7 @@ fslmc_vfio_open_container_fd(void)
return vfio_container_fd;
err_exit:
- if (mp_reply.msgs)
- free(mp_reply.msgs);
+ free(mp_reply.msgs);
DPAA2_BUS_ERR("Open container fd err(%d)", ret);
return ret;
}
--
2.45.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/3] net/dpaa2: remove unnecessary check for null before rte_free
2024-11-12 17:38 [PATCH 0/3] unnecessary checks for null Stephen Hemminger
2024-11-12 17:38 ` [PATCH 1/3] bus/fslmc: remove unnecessary null check Stephen Hemminger
@ 2024-11-12 17:38 ` Stephen Hemminger
2024-11-13 5:01 ` Hemant Agrawal
2024-11-12 17:38 ` [PATCH 3/3] net/ntnic: remove unnecessary check for null before free Stephen Hemminger
2024-11-13 1:25 ` [PATCH 0/3] unnecessary checks for null Ferruh Yigit
3 siblings, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2024-11-12 17:38 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, sachin.saxena, Hemant Agrawal, Sachin Saxena
Calling rte_free() with NULL parameter is allowed.
Found by nullfree.cocci
Fixes: 5964d36a2904 ("net/dpaa2: release port upon close")
Cc: sachin.saxena@oss.nxp.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/dpaa2/dpaa2_ethdev.c | 3 +--
drivers/net/dpaa2/dpaa2_flow.c | 27 +++++++++------------------
drivers/net/dpaa2/dpaa2_mux.c | 6 ++----
3 files changed, 12 insertions(+), 24 deletions(-)
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 8cbe481fb5..a9bce854c3 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -1401,8 +1401,7 @@ dpaa2_dev_close(struct rte_eth_dev *dev)
for (i = 0; i < MAX_TCS; i++)
rte_free(priv->extract.tc_extract_param[i]);
- if (priv->extract.qos_extract_param)
- rte_free(priv->extract.qos_extract_param);
+ rte_free(priv->extract.qos_extract_param);
DPAA2_PMD_INFO("%s: netdev deleted", dev->data->name);
return 0;
diff --git a/drivers/net/dpaa2/dpaa2_flow.c b/drivers/net/dpaa2/dpaa2_flow.c
index de850ae0cf..c94eb51ba5 100644
--- a/drivers/net/dpaa2/dpaa2_flow.c
+++ b/drivers/net/dpaa2/dpaa2_flow.c
@@ -4784,8 +4784,7 @@ dpaa2_generic_flow_set(struct dpaa2_dev_flow *flow,
}
}
- if (dpaa2_pattern)
- rte_free(dpaa2_pattern);
+ rte_free(dpaa2_pattern);
return ret;
}
@@ -5057,14 +5056,10 @@ dpaa2_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
creation_error:
if (flow) {
- if (flow->qos_key_addr)
- rte_free(flow->qos_key_addr);
- if (flow->qos_mask_addr)
- rte_free(flow->qos_mask_addr);
- if (flow->fs_key_addr)
- rte_free(flow->fs_key_addr);
- if (flow->fs_mask_addr)
- rte_free(flow->fs_mask_addr);
+ rte_free(flow->qos_key_addr);
+ rte_free(flow->qos_mask_addr);
+ rte_free(flow->fs_key_addr);
+ rte_free(flow->fs_mask_addr);
rte_free(flow);
}
priv->curr = NULL;
@@ -5128,14 +5123,10 @@ dpaa2_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *_flow,
}
LIST_REMOVE(flow, next);
- if (flow->qos_key_addr)
- rte_free(flow->qos_key_addr);
- if (flow->qos_mask_addr)
- rte_free(flow->qos_mask_addr);
- if (flow->fs_key_addr)
- rte_free(flow->fs_key_addr);
- if (flow->fs_mask_addr)
- rte_free(flow->fs_mask_addr);
+ rte_free(flow->qos_key_addr);
+ rte_free(flow->qos_mask_addr);
+ rte_free(flow->fs_key_addr);
+ rte_free(flow->fs_mask_addr);
/* Now free the flow */
rte_free(flow);
diff --git a/drivers/net/dpaa2/dpaa2_mux.c b/drivers/net/dpaa2/dpaa2_mux.c
index e9d48a81a8..2f124313fa 100644
--- a/drivers/net/dpaa2/dpaa2_mux.c
+++ b/drivers/net/dpaa2/dpaa2_mux.c
@@ -329,10 +329,8 @@ rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id,
}
creation_error:
- if (key_cfg_va)
- rte_free(key_cfg_va);
- if (key_va)
- rte_free(key_va);
+ rte_free(key_cfg_va);
+ rte_free(key_va);
return ret;
}
--
2.45.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/3] net/ntnic: remove unnecessary check for null before free
2024-11-12 17:38 [PATCH 0/3] unnecessary checks for null Stephen Hemminger
2024-11-12 17:38 ` [PATCH 1/3] bus/fslmc: remove unnecessary null check Stephen Hemminger
2024-11-12 17:38 ` [PATCH 2/3] net/dpaa2: remove unnecessary check for null before rte_free Stephen Hemminger
@ 2024-11-12 17:38 ` Stephen Hemminger
2024-11-13 1:25 ` [PATCH 0/3] unnecessary checks for null Ferruh Yigit
3 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2024-11-12 17:38 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, okl-plv, Christian Koue Muf, Serhii Iliushyk
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-plv@napatech.com
Signed-off-by: Stephen Hemminger <stephen@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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/3] unnecessary checks for null
2024-11-12 17:38 [PATCH 0/3] unnecessary checks for null Stephen Hemminger
` (2 preceding siblings ...)
2024-11-12 17:38 ` [PATCH 3/3] net/ntnic: remove unnecessary check for null before free Stephen Hemminger
@ 2024-11-13 1:25 ` Ferruh Yigit
2024-11-13 4:56 ` Stephen Hemminger
3 siblings, 1 reply; 8+ messages in thread
From: Ferruh Yigit @ 2024-11-13 1:25 UTC (permalink / raw)
To: Stephen Hemminger, dev
On 11/12/2024 5:38 PM, Stephen Hemminger wrote:
> Found by running nullfree.cocci on 24.11-rc2
>
> Stephen Hemminger (3):
> bus/fslmc: remove unnecessary null check
> net/dpaa2: remove unnecessary check for null before rte_free
> net/ntnic: remove unnecessary check for null before free
>
For series,
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
Btw, script catches 'rte_openssl_pmd.c' for 'EVP_PKEY_free()' call,
which seems ignoring the NULL value, it can be separate patch for crypto
tree.
Series applied to dpdk-next-net/main, thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/3] unnecessary checks for null
2024-11-13 1:25 ` [PATCH 0/3] unnecessary checks for null Ferruh Yigit
@ 2024-11-13 4:56 ` Stephen Hemminger
0 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2024-11-13 4:56 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev
On Wed, 13 Nov 2024 01:25:37 +0000
Ferruh Yigit <ferruh.yigit@amd.com> wrote:
> On 11/12/2024 5:38 PM, Stephen Hemminger wrote:
> > Found by running nullfree.cocci on 24.11-rc2
> >
> > Stephen Hemminger (3):
> > bus/fslmc: remove unnecessary null check
> > net/dpaa2: remove unnecessary check for null before rte_free
> > net/ntnic: remove unnecessary check for null before free
> >
>
> For series,
> Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
>
> Btw, script catches 'rte_openssl_pmd.c' for 'EVP_PKEY_free()' call,
> which seems ignoring the NULL value, it can be separate patch for crypto
> tree.
Right I wanted to check that one more carefully.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] bus/fslmc: remove unnecessary null check
2024-11-12 17:38 ` [PATCH 1/3] bus/fslmc: remove unnecessary null check Stephen Hemminger
@ 2024-11-13 5:01 ` Hemant Agrawal
0 siblings, 0 replies; 8+ messages in thread
From: Hemant Agrawal @ 2024-11-13 5:01 UTC (permalink / raw)
To: Stephen Hemminger, dev; +Cc: jun.yang, Hemant Agrawal, Sachin Saxena
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
On 12-11-2024 23:08, Stephen Hemminger wrote:
> No need for check for null before calling free().
> Caught by nullfree.cocci script.
>
> Fixes: 57cb02edf122 ("bus/fslmc: enhance MC VFIO multi-process support")
> Cc: jun.yang@nxp.com
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> drivers/bus/fslmc/fslmc_vfio.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
> index c581dcc4e2..7a584b9280 100644
> --- a/drivers/bus/fslmc/fslmc_vfio.c
> +++ b/drivers/bus/fslmc/fslmc_vfio.c
> @@ -557,8 +557,7 @@ fslmc_vfio_open_container_fd(void)
> return vfio_container_fd;
>
> err_exit:
> - if (mp_reply.msgs)
> - free(mp_reply.msgs);
> + free(mp_reply.msgs);
> DPAA2_BUS_ERR("Open container fd err(%d)", ret);
> return ret;
> }
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] net/dpaa2: remove unnecessary check for null before rte_free
2024-11-12 17:38 ` [PATCH 2/3] net/dpaa2: remove unnecessary check for null before rte_free Stephen Hemminger
@ 2024-11-13 5:01 ` Hemant Agrawal
0 siblings, 0 replies; 8+ messages in thread
From: Hemant Agrawal @ 2024-11-13 5:01 UTC (permalink / raw)
To: Stephen Hemminger, dev; +Cc: sachin.saxena, Hemant Agrawal, Sachin Saxena
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
On 12-11-2024 23:08, Stephen Hemminger wrote:
> Calling rte_free() with NULL parameter is allowed.
> Found by nullfree.cocci
>
> Fixes: 5964d36a2904 ("net/dpaa2: release port upon close")
> Cc: sachin.saxena@oss.nxp.com
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> drivers/net/dpaa2/dpaa2_ethdev.c | 3 +--
> drivers/net/dpaa2/dpaa2_flow.c | 27 +++++++++------------------
> drivers/net/dpaa2/dpaa2_mux.c | 6 ++----
> 3 files changed, 12 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
> index 8cbe481fb5..a9bce854c3 100644
> --- a/drivers/net/dpaa2/dpaa2_ethdev.c
> +++ b/drivers/net/dpaa2/dpaa2_ethdev.c
> @@ -1401,8 +1401,7 @@ dpaa2_dev_close(struct rte_eth_dev *dev)
> for (i = 0; i < MAX_TCS; i++)
> rte_free(priv->extract.tc_extract_param[i]);
>
> - if (priv->extract.qos_extract_param)
> - rte_free(priv->extract.qos_extract_param);
> + rte_free(priv->extract.qos_extract_param);
>
> DPAA2_PMD_INFO("%s: netdev deleted", dev->data->name);
> return 0;
> diff --git a/drivers/net/dpaa2/dpaa2_flow.c b/drivers/net/dpaa2/dpaa2_flow.c
> index de850ae0cf..c94eb51ba5 100644
> --- a/drivers/net/dpaa2/dpaa2_flow.c
> +++ b/drivers/net/dpaa2/dpaa2_flow.c
> @@ -4784,8 +4784,7 @@ dpaa2_generic_flow_set(struct dpaa2_dev_flow *flow,
> }
> }
>
> - if (dpaa2_pattern)
> - rte_free(dpaa2_pattern);
> + rte_free(dpaa2_pattern);
>
> return ret;
> }
> @@ -5057,14 +5056,10 @@ dpaa2_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
>
> creation_error:
> if (flow) {
> - if (flow->qos_key_addr)
> - rte_free(flow->qos_key_addr);
> - if (flow->qos_mask_addr)
> - rte_free(flow->qos_mask_addr);
> - if (flow->fs_key_addr)
> - rte_free(flow->fs_key_addr);
> - if (flow->fs_mask_addr)
> - rte_free(flow->fs_mask_addr);
> + rte_free(flow->qos_key_addr);
> + rte_free(flow->qos_mask_addr);
> + rte_free(flow->fs_key_addr);
> + rte_free(flow->fs_mask_addr);
> rte_free(flow);
> }
> priv->curr = NULL;
> @@ -5128,14 +5123,10 @@ dpaa2_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *_flow,
> }
>
> LIST_REMOVE(flow, next);
> - if (flow->qos_key_addr)
> - rte_free(flow->qos_key_addr);
> - if (flow->qos_mask_addr)
> - rte_free(flow->qos_mask_addr);
> - if (flow->fs_key_addr)
> - rte_free(flow->fs_key_addr);
> - if (flow->fs_mask_addr)
> - rte_free(flow->fs_mask_addr);
> + rte_free(flow->qos_key_addr);
> + rte_free(flow->qos_mask_addr);
> + rte_free(flow->fs_key_addr);
> + rte_free(flow->fs_mask_addr);
> /* Now free the flow */
> rte_free(flow);
>
> diff --git a/drivers/net/dpaa2/dpaa2_mux.c b/drivers/net/dpaa2/dpaa2_mux.c
> index e9d48a81a8..2f124313fa 100644
> --- a/drivers/net/dpaa2/dpaa2_mux.c
> +++ b/drivers/net/dpaa2/dpaa2_mux.c
> @@ -329,10 +329,8 @@ rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id,
> }
>
> creation_error:
> - if (key_cfg_va)
> - rte_free(key_cfg_va);
> - if (key_va)
> - rte_free(key_va);
> + rte_free(key_cfg_va);
> + rte_free(key_va);
>
> return ret;
> }
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-11-13 5:01 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-12 17:38 [PATCH 0/3] unnecessary checks for null Stephen Hemminger
2024-11-12 17:38 ` [PATCH 1/3] bus/fslmc: remove unnecessary null check Stephen Hemminger
2024-11-13 5:01 ` Hemant Agrawal
2024-11-12 17:38 ` [PATCH 2/3] net/dpaa2: remove unnecessary check for null before rte_free Stephen Hemminger
2024-11-13 5:01 ` Hemant Agrawal
2024-11-12 17:38 ` [PATCH 3/3] net/ntnic: remove unnecessary check for null before free Stephen Hemminger
2024-11-13 1:25 ` [PATCH 0/3] unnecessary checks for null Ferruh Yigit
2024-11-13 4:56 ` Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).