static void kcryptd_async_done(struct crypto_async_request *async_req,
                               int error);
 
-static void crypt_alloc_req_skcipher(struct crypt_config *cc,
+static int crypt_alloc_req_skcipher(struct crypt_config *cc,
                                     struct convert_context *ctx)
 {
        unsigned key_index = ctx->cc_sector & (cc->tfms_count - 1);
 
-       if (!ctx->r.req)
-               ctx->r.req = mempool_alloc(&cc->req_pool, GFP_NOIO);
+       if (!ctx->r.req) {
+               ctx->r.req = mempool_alloc(&cc->req_pool, in_interrupt() ? GFP_ATOMIC : GFP_NOIO);
+               if (!ctx->r.req)
+                       return -ENOMEM;
+       }
 
        skcipher_request_set_tfm(ctx->r.req, cc->cipher_tfm.tfms[key_index]);
 
        skcipher_request_set_callback(ctx->r.req,
            CRYPTO_TFM_REQ_MAY_BACKLOG,
            kcryptd_async_done, dmreq_of_req(cc, ctx->r.req));
+
+       return 0;
 }
 
-static void crypt_alloc_req_aead(struct crypt_config *cc,
+static int crypt_alloc_req_aead(struct crypt_config *cc,
                                 struct convert_context *ctx)
 {
-       if (!ctx->r.req_aead)
-               ctx->r.req_aead = mempool_alloc(&cc->req_pool, GFP_NOIO);
+       if (!ctx->r.req) {
+               ctx->r.req = mempool_alloc(&cc->req_pool, in_interrupt() ? GFP_ATOMIC : GFP_NOIO);
+               if (!ctx->r.req)
+                       return -ENOMEM;
+       }
 
        aead_request_set_tfm(ctx->r.req_aead, cc->cipher_tfm.tfms_aead[0]);
 
        aead_request_set_callback(ctx->r.req_aead,
            CRYPTO_TFM_REQ_MAY_BACKLOG,
            kcryptd_async_done, dmreq_of_req(cc, ctx->r.req_aead));
+
+       return 0;
 }
 
-static void crypt_alloc_req(struct crypt_config *cc,
+static int crypt_alloc_req(struct crypt_config *cc,
                            struct convert_context *ctx)
 {
        if (crypt_integrity_aead(cc))
-               crypt_alloc_req_aead(cc, ctx);
+               return crypt_alloc_req_aead(cc, ctx);
        else
-               crypt_alloc_req_skcipher(cc, ctx);
+               return crypt_alloc_req_skcipher(cc, ctx);
 }
 
 static void crypt_free_req_skcipher(struct crypt_config *cc,
 
        while (ctx->iter_in.bi_size && ctx->iter_out.bi_size) {
 
-               crypt_alloc_req(cc, ctx);
+               r = crypt_alloc_req(cc, ctx);
+               if (r) {
+                       complete(&ctx->restart);
+                       return BLK_STS_DEV_RESOURCE;
+               }
+
                atomic_inc(&ctx->cc_pending);
 
                if (crypt_integrity_aead(cc))