@@ -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 {
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 <dan.carpenter@oracle.com> 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(-)