DORMANTno replies

[PATCH net] ch_ktls: Remove the checks for u_ctx pointer

From: Ayush Sawal <ayush.sawal@chelsio.com>
Date: 2021-05-18 05:53:16
Subsystem: cxgb4 inline crypto driver, networking drivers, the rest · Maintainers: Ayush Sawal, Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

The u_ctx pointer in case of ch_ktls will always be valid. As u_ctx is
ch_ktls ctx pointer and remains valid until driver is running.

So removing the u_ctx checks.

Fixes: 65e302a9bd57 ("cxgb4/ch_ktls: Clear resources when pf4 device is removed")
Reported-by: Dan Carpenter <redacted>
Signed-off-by: Ayush Sawal <ayush.sawal@chelsio.com>
---
 .../chelsio/inline_crypto/ch_ktls/chcr_ktls.c | 20 +++++++++----------
 1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c b/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c
index 59683f79959c..82f847cecf90 100644
--- a/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c
+++ b/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c
@@ -371,7 +371,7 @@ static void chcr_ktls_dev_del(struct net_device *netdev,
 		return;
 
 	u_ctx = tx_info->adap->uld[CXGB4_ULD_KTLS].handle;
-	if (u_ctx && u_ctx->detach)
+	if (u_ctx->detach)
 		return;
 	/* clear l2t entry */
 	if (tx_info->l2te)
@@ -443,7 +443,7 @@ static int chcr_ktls_dev_add(struct net_device *netdev, struct sock *sk,
 	if (tx_ctx->chcr_info)
 		goto out;
 
-	if (u_ctx && u_ctx->detach)
+	if (u_ctx->detach)
 		goto out;
 
 	tx_info = kvzalloc(sizeof(*tx_info), GFP_KERNEL);
@@ -688,15 +688,13 @@ static int chcr_ktls_cpl_act_open_rpl(struct adapter *adap,
 		tls_ctx = tls_get_ctx(tx_info->sk);
 		tx_ctx = chcr_get_ktls_tx_context(tls_ctx);
 		u_ctx = adap->uld[CXGB4_ULD_KTLS].handle;
-		if (u_ctx) {
-			ret = xa_insert_bh(&u_ctx->tid_list, tid, tx_ctx,
-					   GFP_NOWAIT);
-			if (ret < 0) {
-				pr_err("%s: Failed to allocate tid XA entry = %d\n",
-				       __func__, tx_info->tid);
-				tx_info->open_state = CH_KTLS_OPEN_FAILURE;
-				goto out;
-			}
+		ret = xa_insert_bh(&u_ctx->tid_list, tid, tx_ctx,
+				   GFP_NOWAIT);
+		if (ret < 0) {
+			pr_err("%s: Failed to allocate tid XA entry = %d\n",
+			       __func__, tx_info->tid);
+			tx_info->open_state = CH_KTLS_OPEN_FAILURE;
+			goto out;
 		}
 		tx_info->open_state = CH_KTLS_OPEN_SUCCESS;
 	} else {
-- 
2.28.0.rc1.6.gae46588
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help