Skip to contentSkip to conversation

ipsec: remove unneccessary null check

PATCH Applied Stephen Hemminger 5 participants 5 messages Jan 13, 2023 – Jan 31, 2023 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/crypto/ipsec_mb/ipsec_mb_ops.c +1 -4
index 71e02cd0513d..3e52f9567401 100644
@@ -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)
Signature · 1 line
2.39.0
Acked-by on v1 1/1
#1 lore raw
Quoted 24 lines · Stephen Hemminger

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")
---
 drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/crypto/ipsec_mb/ipsec_mb_ops.c +0 -1
index 71e02cd0513d..3e52f9567401 100644
@@ -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)

drivers/crypto/ipsec_mb/ipsec_mb_ops.c int · line 150

Quoted 10 lines
drivers/crypto/ipsec_mb/ipsec_mb_ops.c +1 -3
 		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 on v1 1/1
#2 lore raw
In reply to Stephen Hemminger
Quoted 23 lines · Stephen Hemminger

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")
---
  drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
drivers/crypto/ipsec_mb/ipsec_mb_ops.c +0 -1
index 71e02cd0513d..3e52f9567401 100644
@@ -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)

drivers/crypto/ipsec_mb/ipsec_mb_ops.c int · line 150

Quoted 10 lines
drivers/crypto/ipsec_mb/ipsec_mb_ops.c +1 -3
  		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 on v1 1/1
#3 lore raw
In reply to Stephen Hemminger
Quoted 44 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Friday, January 13, 2023 6:44 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>; Ji, Kai <[email protected]>; De Lara Guarch, Pablo <[email protected]>; Power, Ciara <[email protected]>
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")
---
 drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/crypto/ipsec_mb/ipsec_mb_ops.c +1 -5
index 71e02cd0513d..3e52f9567401 100644
@@ -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

Applied
#4 lore raw
In reply to Stephen Hemminger
Quoted 1 line

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.

Quoted 37 lines

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")
---
 drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/crypto/ipsec_mb/ipsec_mb_ops.c +1 -5
index 71e02cd0513d..3e52f9567401 100644
@@ -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