DPDK patches and discussions
 help / color / mirror / Atom feed
From: Hemant Agrawal <hemant.agrawal@oss.nxp.com>
To: Stephen Hemminger <stephen@networkplumber.org>, dev@dpdk.org
Cc: sachin.saxena@oss.nxp.com,
	Hemant Agrawal <hemant.agrawal@nxp.com>,
	Sachin Saxena <sachin.saxena@nxp.com>
Subject: Re: [PATCH 2/3] net/dpaa2: remove unnecessary check for null before rte_free
Date: Wed, 13 Nov 2024 10:31:43 +0530	[thread overview]
Message-ID: <d0c3e628-2985-b23a-020c-7e65b16ffa27@oss.nxp.com> (raw)
In-Reply-To: <20241112173833.323934-3-stephen@networkplumber.org>

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;
>   }

  reply	other threads:[~2024-11-13  5:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d0c3e628-2985-b23a-020c-7e65b16ffa27@oss.nxp.com \
    --to=hemant.agrawal@oss.nxp.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=sachin.saxena@nxp.com \
    --cc=sachin.saxena@oss.nxp.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).