kctx_len = (DIV_ROUND_UP(ablkctx->enckey_len, 16) * 16);
        transhdr_len = CIPHER_TRANSHDR_SIZE(kctx_len, phys_dsgl);
        skb = alloc_skb((transhdr_len + sizeof(struct sge_opaque_hdr)), flags);
 -      if (!skb)
 -              return ERR_PTR(-ENOMEM);
 +      if (!skb) {
 +              error = -ENOMEM;
 +              goto err;
 +      }
        skb_reserve(skb, sizeof(struct sge_opaque_hdr));
-       chcr_req = (struct chcr_wr *)__skb_put(skb, transhdr_len);
-       memset(chcr_req, 0, transhdr_len);
+       chcr_req = __skb_put_zero(skb, transhdr_len);
        chcr_req->sec_cpl.op_ivinsrtofst =
                FILL_SEC_CPL_OP_IVINSR(ctx->dev->rx_channel_id, 2, 1);
  
        /* NIC driver is going to write the sge hdr. */
        skb_reserve(skb, sizeof(struct sge_opaque_hdr));
  
-       chcr_req = (struct chcr_wr *)__skb_put(skb, transhdr_len);
-       memset(chcr_req, 0, transhdr_len);
+       chcr_req = __skb_put_zero(skb, transhdr_len);
  
        if (get_aead_subtype(tfm) == CRYPTO_ALG_SUB_TYPE_AEAD_RFC4106)
 -              req->assoclen -= 8;
 +              assoclen = req->assoclen - 8;
  
        tag_offset = (op_type == CHCR_ENCRYPT_OP) ? 0 : authsize;
        chcr_req->sec_cpl.op_ivinsrtofst = FILL_SEC_CPL_OP_IVINSR(
 
                hidp_process_transmit(session, &session->ctrl_transmit,
                                      session->ctrl_sock);
  
-               schedule();
+               wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
        }
+       remove_wait_queue(&hidp_session_wq, &wait);
  
        atomic_inc(&session->terminate);
-       set_current_state(TASK_RUNNING);
+ 
+       /* Ensure session->terminate is updated */
+       smp_mb__after_atomic();
+ }
+ 
 -static int hidp_session_wake_function(wait_queue_t *wait,
++static int hidp_session_wake_function(wait_queue_entry_t *wait,
+                                     unsigned int mode,
+                                     int sync, void *key)
+ {
+       wake_up_interruptible(&hidp_session_wq);
+       return false;
  }
  
  /*