* [PATCH] net/bnxt: remove unnecessary checks for null pointer
@ 2025-01-28 17:42 Stephen Hemminger
2025-01-28 17:54 ` Ajit Khaparde
0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2025-01-28 17:42 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Ajit Khaparde, Somnath Kotur
The function rte_free() handles a NULL pointer as no-op.
This patch was automatically generated from nullfree.cocci script.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/bnxt/tf_core/v3/tfc_tbl_scope.c | 6 ++----
drivers/net/bnxt/tf_ulp/ulp_mapper.c | 3 +--
drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c | 6 ++----
3 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/net/bnxt/tf_core/v3/tfc_tbl_scope.c b/drivers/net/bnxt/tf_core/v3/tfc_tbl_scope.c
index 1770069295..f88299bbf7 100644
--- a/drivers/net/bnxt/tf_core/v3/tfc_tbl_scope.c
+++ b/drivers/net/bnxt/tf_core/v3/tfc_tbl_scope.c
@@ -1668,10 +1668,8 @@ int tfc_tbl_scope_cpm_alloc(struct tfc *tfcp, uint8_t tsid,
return 0;
cleanup:
- if (cmm_lkup != NULL)
- rte_free(cmm_lkup);
- if (cmm_act != NULL)
- rte_free(cmm_act);
+ rte_free(cmm_lkup);
+ rte_free(cmm_act);
return rc;
}
diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
index 2429ac2f1a..49cd6620dd 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
@@ -1359,8 +1359,7 @@ ulp_mapper_key_recipe_tbl_deinit(struct bnxt_ulp_mapper_data *mdata)
recipes = mdata->key_recipe_info.recipes[dir][ftype];
for (idx = 0; idx < mdata->key_recipe_info.num_recipes;
idx++) {
- if (recipes[idx])
- rte_free(recipes[idx]);
+ rte_free(recipes[idx]);
}
rte_free(mdata->key_recipe_info.recipes[dir][ftype]);
mdata->key_recipe_info.recipes[dir][ftype] = NULL;
diff --git a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c
index 5fa8e240db..85b72f328c 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c
@@ -158,11 +158,9 @@ ulp_sc_mgr_deinit(struct bnxt_ulp_context *ctxt)
if (!ulp_sc_info)
return -EINVAL;
- 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);
rte_free(ulp_sc_info);
--
2.45.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] net/bnxt: remove unnecessary checks for null pointer
2025-01-28 17:42 [PATCH] net/bnxt: remove unnecessary checks for null pointer Stephen Hemminger
@ 2025-01-28 17:54 ` Ajit Khaparde
0 siblings, 0 replies; 2+ messages in thread
From: Ajit Khaparde @ 2025-01-28 17:54 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev, Somnath Kotur
[-- Attachment #1: Type: text/plain, Size: 2801 bytes --]
On Tue, Jan 28, 2025 at 9:42 AM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> The function rte_free() handles a NULL pointer as no-op.
> This patch was automatically generated from nullfree.cocci script.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
> ---
> drivers/net/bnxt/tf_core/v3/tfc_tbl_scope.c | 6 ++----
> drivers/net/bnxt/tf_ulp/ulp_mapper.c | 3 +--
> drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c | 6 ++----
> 3 files changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/bnxt/tf_core/v3/tfc_tbl_scope.c b/drivers/net/bnxt/tf_core/v3/tfc_tbl_scope.c
> index 1770069295..f88299bbf7 100644
> --- a/drivers/net/bnxt/tf_core/v3/tfc_tbl_scope.c
> +++ b/drivers/net/bnxt/tf_core/v3/tfc_tbl_scope.c
> @@ -1668,10 +1668,8 @@ int tfc_tbl_scope_cpm_alloc(struct tfc *tfcp, uint8_t tsid,
> return 0;
>
> cleanup:
> - if (cmm_lkup != NULL)
> - rte_free(cmm_lkup);
> - if (cmm_act != NULL)
> - rte_free(cmm_act);
> + rte_free(cmm_lkup);
> + rte_free(cmm_act);
>
> return rc;
> }
> diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
> index 2429ac2f1a..49cd6620dd 100644
> --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
> +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
> @@ -1359,8 +1359,7 @@ ulp_mapper_key_recipe_tbl_deinit(struct bnxt_ulp_mapper_data *mdata)
> recipes = mdata->key_recipe_info.recipes[dir][ftype];
> for (idx = 0; idx < mdata->key_recipe_info.num_recipes;
> idx++) {
> - if (recipes[idx])
> - rte_free(recipes[idx]);
> + rte_free(recipes[idx]);
> }
> rte_free(mdata->key_recipe_info.recipes[dir][ftype]);
> mdata->key_recipe_info.recipes[dir][ftype] = NULL;
> diff --git a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c
> index 5fa8e240db..85b72f328c 100644
> --- a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c
> +++ b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c
> @@ -158,11 +158,9 @@ ulp_sc_mgr_deinit(struct bnxt_ulp_context *ctxt)
> if (!ulp_sc_info)
> return -EINVAL;
>
> - 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);
>
> rte_free(ulp_sc_info);
>
> --
> 2.45.2
>
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4218 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-28 17:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-28 17:42 [PATCH] net/bnxt: remove unnecessary checks for null pointer Stephen Hemminger
2025-01-28 17:54 ` Ajit Khaparde
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).