}
 }
 
-static int chacha_simd_stream_xor(struct skcipher_request *req,
+static int chacha_simd_stream_xor(struct skcipher_walk *walk,
                                  struct chacha_ctx *ctx, u8 *iv)
 {
        u32 *state, state_buf[16 + 2] __aligned(8);
-       struct skcipher_walk walk;
        int next_yield = 4096; /* bytes until next FPU yield */
-       int err;
+       int err = 0;
 
        BUILD_BUG_ON(CHACHA_STATE_ALIGN != 16);
        state = PTR_ALIGN(state_buf + 0, CHACHA_STATE_ALIGN);
 
-       err = skcipher_walk_virt(&walk, req, true);
-
        crypto_chacha_init(state, ctx, iv);
 
-       while (walk.nbytes > 0) {
-               unsigned int nbytes = walk.nbytes;
+       while (walk->nbytes > 0) {
+               unsigned int nbytes = walk->nbytes;
 
-               if (nbytes < walk.total) {
-                       nbytes = round_down(nbytes, walk.stride);
+               if (nbytes < walk->total) {
+                       nbytes = round_down(nbytes, walk->stride);
                        next_yield -= nbytes;
                }
 
-               chacha_dosimd(state, walk.dst.virt.addr, walk.src.virt.addr,
+               chacha_dosimd(state, walk->dst.virt.addr, walk->src.virt.addr,
                              nbytes, ctx->nrounds);
 
                if (next_yield <= 0) {
                        next_yield = 4096;
                }
 
-               err = skcipher_walk_done(&walk, walk.nbytes - nbytes);
+               err = skcipher_walk_done(walk, walk->nbytes - nbytes);
        }
 
        return err;
 {
        struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
        struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm);
+       struct skcipher_walk walk;
        int err;
 
        if (req->cryptlen <= CHACHA_BLOCK_SIZE || !irq_fpu_usable())
                return crypto_chacha_crypt(req);
 
+       err = skcipher_walk_virt(&walk, req, true);
+       if (err)
+               return err;
+
        kernel_fpu_begin();
-       err = chacha_simd_stream_xor(req, ctx, req->iv);
+       err = chacha_simd_stream_xor(&walk, ctx, req->iv);
        kernel_fpu_end();
        return err;
 }
 {
        struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
        struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm);
+       struct skcipher_walk walk;
        struct chacha_ctx subctx;
        u32 *state, state_buf[16 + 2] __aligned(8);
        u8 real_iv[16];
        if (req->cryptlen <= CHACHA_BLOCK_SIZE || !irq_fpu_usable())
                return crypto_xchacha_crypt(req);
 
+       err = skcipher_walk_virt(&walk, req, true);
+       if (err)
+               return err;
+
        BUILD_BUG_ON(CHACHA_STATE_ALIGN != 16);
        state = PTR_ALIGN(state_buf + 0, CHACHA_STATE_ALIGN);
        crypto_chacha_init(state, ctx, req->iv);
 
        memcpy(&real_iv[0], req->iv + 24, 8);
        memcpy(&real_iv[8], req->iv + 16, 8);
-       err = chacha_simd_stream_xor(req, &subctx, real_iv);
+       err = chacha_simd_stream_xor(&walk, &subctx, real_iv);
 
        kernel_fpu_end();