ipsec: remove unneccessary null check

Message ID 20230113184426.68063-1-stephen@networkplumber.org (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series ipsec: remove unneccessary null check |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-broadcom-Performance fail Performance Testing issues
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Stephen Hemminger Jan. 13, 2023, 6:44 p.m. UTC
  The function rte_ring_free() accepts NULL as vaild input
like free() and other functions.

Found with null_free_check.cocci.

Fixes: 16d6ebb65d59 ("crypto/ipsec_mb: fix null checks")
Cc: kai.ji@intel.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
  

Comments

Tyler Retzlaff Jan. 13, 2023, 7:04 p.m. UTC | #1
On Fri, Jan 13, 2023 at 10:44:25AM -0800, Stephen Hemminger wrote:
> The function rte_ring_free() accepts NULL as vaild input
> like free() and other functions.
> 
> Found with null_free_check.cocci.
> 
> Fixes: 16d6ebb65d59 ("crypto/ipsec_mb: fix null checks")
> Cc: kai.ji@intel.com
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> index 71e02cd0513d..3e52f9567401 100644
> --- a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> +++ b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> @@ -139,15 +139,12 @@ int
>  ipsec_mb_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
>  {
>  	struct ipsec_mb_qp *qp = dev->data->queue_pairs[qp_id];
> -	struct rte_ring *r = NULL;
>  
>  	if (!qp)
>  		return 0;
>  
>  	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
> -		r = rte_ring_lookup(qp->name);
> -		if (r)
> -			rte_ring_free(r);
> +		rte_ring_free(rte_ring_lookup(qp->name));
>  
>  #if IMB_VERSION(1, 1, 0) > IMB_VERSION_NUM
>  		if (qp->mb_mgr)
> -- 

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
  
Zhang, Fan Jan. 16, 2023, 9:16 a.m. UTC | #2
On 1/13/2023 6:44 PM, Stephen Hemminger wrote:
> The function rte_ring_free() accepts NULL as vaild input
> like free() and other functions.
>
> Found with null_free_check.cocci.
>
> Fixes: 16d6ebb65d59 ("crypto/ipsec_mb: fix null checks")
> Cc: kai.ji@intel.com
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>   drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> index 71e02cd0513d..3e52f9567401 100644
> --- a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> +++ b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> @@ -139,15 +139,12 @@ int
>   ipsec_mb_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
>   {
>   	struct ipsec_mb_qp *qp = dev->data->queue_pairs[qp_id];
> -	struct rte_ring *r = NULL;
>   
>   	if (!qp)
>   		return 0;
>   
>   	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
> -		r = rte_ring_lookup(qp->name);
> -		if (r)
> -			rte_ring_free(r);
> +		rte_ring_free(rte_ring_lookup(qp->name));
>   
>   #if IMB_VERSION(1, 1, 0) > IMB_VERSION_NUM
>   		if (qp->mb_mgr)
Acked-by: Fan Zhang <fanzhang.oss@gmail.com>
  
Ji, Kai Jan. 16, 2023, 11:28 p.m. UTC | #3
Acked-by: Kai Ji <kai.ji@intel.com>

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Friday, January 13, 2023 6:44 PM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Ji, Kai
> <kai.ji@intel.com>; De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;
> Power, Ciara <ciara.power@intel.com>
> Subject: [PATCH] ipsec: remove unneccessary null check
> 
> The function rte_ring_free() accepts NULL as vaild input like free() and
> other functions.
> 
> Found with null_free_check.cocci.
> 
> Fixes: 16d6ebb65d59 ("crypto/ipsec_mb: fix null checks")
> Cc: kai.ji@intel.com
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> index 71e02cd0513d..3e52f9567401 100644
> --- a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> +++ b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> @@ -139,15 +139,12 @@ int
>  ipsec_mb_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)  {
>  	struct ipsec_mb_qp *qp = dev->data->queue_pairs[qp_id];
> -	struct rte_ring *r = NULL;
> 
>  	if (!qp)
>  		return 0;
> 
>  	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
> -		r = rte_ring_lookup(qp->name);
> -		if (r)
> -			rte_ring_free(r);
> +		rte_ring_free(rte_ring_lookup(qp->name));
> 
>  #if IMB_VERSION(1, 1, 0) > IMB_VERSION_NUM
>  		if (qp->mb_mgr)
> --
> 2.39.0
  
Akhil Goyal Jan. 31, 2023, 8:17 a.m. UTC | #4
> Subject: [EXT] [PATCH] ipsec: remove unneccessary null check
Changed subject to crypto/ipsec_mb: remove unnecessary null check

Fixed couple of spellings in description and title.

Applied to dpdk-next-crypto

Thanks.
> 
> The function rte_ring_free() accepts NULL as vaild input
> like free() and other functions.
> 
> Found with null_free_check.cocci.
> 
> Fixes: 16d6ebb65d59 ("crypto/ipsec_mb: fix null checks")
> Cc: kai.ji@intel.com
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> index 71e02cd0513d..3e52f9567401 100644
> --- a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> +++ b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> @@ -139,15 +139,12 @@ int
>  ipsec_mb_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
>  {
>  	struct ipsec_mb_qp *qp = dev->data->queue_pairs[qp_id];
> -	struct rte_ring *r = NULL;
> 
>  	if (!qp)
>  		return 0;
> 
>  	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
> -		r = rte_ring_lookup(qp->name);
> -		if (r)
> -			rte_ring_free(r);
> +		rte_ring_free(rte_ring_lookup(qp->name));
> 
>  #if IMB_VERSION(1, 1, 0) > IMB_VERSION_NUM
>  		if (qp->mb_mgr)
> --
> 2.39.0
  

Patch

diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
index 71e02cd0513d..3e52f9567401 100644
--- a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
+++ b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
@@ -139,15 +139,12 @@  int
 ipsec_mb_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 {
 	struct ipsec_mb_qp *qp = dev->data->queue_pairs[qp_id];
-	struct rte_ring *r = NULL;
 
 	if (!qp)
 		return 0;
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
-		r = rte_ring_lookup(qp->name);
-		if (r)
-			rte_ring_free(r);
+		rte_ring_free(rte_ring_lookup(qp->name));
 
 #if IMB_VERSION(1, 1, 0) > IMB_VERSION_NUM
 		if (qp->mb_mgr)