|SUCCESS| [4/4] app/test_compress: remove unnecessary null check
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Wed Apr 1 23:16:42 CEST 2026
Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/162817
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-04-01
Reviewing patch series: removal of unnecessary null checks before free()
commit: 20260401164108.201404-2-stephen at networkplumber.org
Author: Stephen Hemminger <stephen at networkplumber.org>
Subject: net/ice: remove unnecessary null check
This patch removes redundant null pointer checks before calling free() in
the ice_dcf_sched.c file, as free(NULL) is safe according to the C
standard.
> diff --git a/drivers/net/intel/ice/ice_dcf_sched.c b/drivers/net/intel/ice/ice_dcf_sched.c
> index 948774a282..14e902edbe 100644
> --- a/drivers/net/intel/ice/ice_dcf_sched.c
> +++ b/drivers/net/intel/ice/ice_dcf_sched.c
> @@ -877,10 +877,8 @@ static int ice_dcf_hierarchy_commit(struct rte_eth_dev *dev,
> return ret_val;
>
> fail_clear:
> - if (vf_bw != NULL)
> - free(vf_bw);
> - if (tc_bw != NULL)
> - free(tc_bw);
> + free(vf_bw);
> + free(tc_bw);
The changes look correct. The removed null checks are indeed unnecessary
since free(NULL) is a no-op. This simplification improves code
readability.
[ ... ]
---
commit: 20260401164108.201404-3-stephen at networkplumber.org
Author: Stephen Hemminger <stephen at networkplumber.org>
Subject: net/bnxt: remove unnecessary null check
This patch removes redundant null pointer checks before calling rte_free()
in the bnxt driver files.
> diff --git a/drivers/net/bnxt/tf_core/v3/tfo.c b/drivers/net/bnxt/tf_core/v3/tfo.c
> index 4b1f545476..681d1dd8d3 100644
> --- a/drivers/net/bnxt/tf_core/v3/tfo.c
> +++ b/drivers/net/bnxt/tf_core/v3/tfo.c
> @@ -183,13 +183,11 @@ void tfo_close(void **tfo)
> }
> }
> }
> - if (tim)
> - rte_free(tim);
> + rte_free(tim);
> tfco->ts_tim = NULL;
> tfco->tfgo = NULL;
>
> - if (*tfo)
> - rte_free(*tfo);
> + rte_free(*tfo);
Can this code dereference a null pointer in tfco? The function
dereferences tfco->ts_tim and tfco->tfgo after calling rte_free(*tfo),
but does not verify tfco is non-null before these assignments.
> *tfo = NULL;
> }
> }
Does this code crash if tfo_close() is called with a null tfo parameter?
The function checks if (*tfo) is null at the start, but then dereferences
*tfo unconditionally in the rte_free(*tfo) call and *tfo = NULL
assignment after removing the null check.
> diff --git a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c
> index 23e1b59ca4..3707cd1a2d 100644
> --- a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c
> +++ b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c
> @@ -169,11 +169,9 @@ ulp_sc_mgr_deinit(struct bnxt_ulp_context *ctxt)
>
> ulp_sc_mgr_thread_cancel(ctxt);
>
> - if (ulp_sc_info->stats_cache_tbl)
> - rte_free(ulp_sc_info->stats_cache_tbl);
> + rte_free(ulp_sc_info->stats_cache_tbl);
>
> - if (ulp_sc_info->read_data)
> - rte_free(ulp_sc_info->read_data);
> + rte_free(ulp_sc_info->read_data);
These changes are correct, as rte_free(NULL) is safe.
[ ... ]
---
commit: 20260401164108.201404-4-stephen at networkplumber.org
Author: Stephen Hemminger <stephen at networkplumber.org>
Subject: net/zxdh: remove unnecessary null check
This patch removes a redundant null pointer check before calling free() in
the zxdh_np.c file.
> diff --git a/drivers/net/zxdh/zxdh_np.c b/drivers/net/zxdh/zxdh_np.c
> index efb57e34f2..b078ec5b6c 100644
> --- a/drivers/net/zxdh/zxdh_np.c
> +++ b/drivers/net/zxdh/zxdh_np.c
> @@ -12383,8 +12383,7 @@ zxdh_np_dtb_acl_data_clear(uint32_t dev_id, uint32_t queue_id,
> &element_id);
> free(data_buff);
> free(mask_buff);
> - if (eram_buff)
> - free(eram_buff);
> + free(eram_buff);
This change is correct. The null check is unnecessary.
[ ... ]
---
commit: 20260401164108.201404-5-stephen at networkplumber.org
Author: Stephen Hemminger <stephen at networkplumber.org>
Subject: app/test_compress: remove unnecessary null check
This patch removes redundant null pointer checks before calling rte_free()
in the test-compress-perf application.
> diff --git a/app/test-compress-perf/main.c b/app/test-compress-perf/main.c
> index c9ead02cb4..bc2b185da4 100644
> --- a/app/test-compress-perf/main.c
> +++ b/app/test-compress-perf/main.c
> @@ -392,15 +392,13 @@ comp_perf_dump_dictionary_data(struct comp_test_data *td)
>
> if (fread(data, data_to_read, 1, f) != 1) {
> RTE_LOG(ERR, USER1, "Input file could not be read\n");
> - if (td->dictionary_data)
> - rte_free(td->dictionary_data);
> + rte_free(td->dictionary_data);
> goto end;
> }
> if (fseek(f, 0, SEEK_SET) != 0) {
> RTE_LOG(ERR, USER1,
> "Size of input could not be calculated\n");
> - if (td->dictionary_data)
> - rte_free(td->dictionary_data);
> + rte_free(td->dictionary_data);
These changes are correct. The null checks are unnecessary as
rte_free(NULL) is safe.
[ ... ]
More information about the test-report
mailing list