Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: rk3288 - use API helpers to setup fallback request

Rather than setting up the fallback request by hand, use
ahash_request_set_callback() and ahash_request_set_crypt() API helpers
to properly setup the new request.

This also ensures that the completion callback is properly passed down
to the fallback algorithm, which avoids a crash with async fallbacks.

Signed-off-by: Ovidiu Panait <ovidiu.panait.oss@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Ovidiu Panait and committed by
Herbert Xu
cbc9f5bc 2f0c856a

+27 -25
+27 -25
drivers/crypto/rockchip/rk3288_crypto_ahash.c
··· 52 52 algt->stat_fb++; 53 53 54 54 ahash_request_set_tfm(&rctx->fallback_req, tfmctx->fallback_tfm); 55 - rctx->fallback_req.base.flags = areq->base.flags & 56 - CRYPTO_TFM_REQ_MAY_SLEEP; 57 - 58 - rctx->fallback_req.nbytes = areq->nbytes; 59 - rctx->fallback_req.src = areq->src; 60 - rctx->fallback_req.result = areq->result; 55 + ahash_request_set_callback(&rctx->fallback_req, 56 + areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, 57 + areq->base.complete, areq->base.data); 58 + ahash_request_set_crypt(&rctx->fallback_req, areq->src, areq->result, 59 + areq->nbytes); 61 60 62 61 return crypto_ahash_digest(&rctx->fallback_req); 63 62 } ··· 123 124 struct rk_ahash_ctx *ctx = crypto_ahash_ctx(tfm); 124 125 125 126 ahash_request_set_tfm(&rctx->fallback_req, ctx->fallback_tfm); 126 - rctx->fallback_req.base.flags = req->base.flags & 127 - CRYPTO_TFM_REQ_MAY_SLEEP; 127 + ahash_request_set_callback(&rctx->fallback_req, 128 + req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, 129 + req->base.complete, req->base.data); 128 130 129 131 return crypto_ahash_init(&rctx->fallback_req); 130 132 } ··· 137 137 struct rk_ahash_ctx *ctx = crypto_ahash_ctx(tfm); 138 138 139 139 ahash_request_set_tfm(&rctx->fallback_req, ctx->fallback_tfm); 140 - rctx->fallback_req.base.flags = req->base.flags & 141 - CRYPTO_TFM_REQ_MAY_SLEEP; 142 - rctx->fallback_req.nbytes = req->nbytes; 143 - rctx->fallback_req.src = req->src; 140 + ahash_request_set_callback(&rctx->fallback_req, 141 + req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, 142 + req->base.complete, req->base.data); 143 + ahash_request_set_crypt(&rctx->fallback_req, req->src, NULL, req->nbytes); 144 144 145 145 return crypto_ahash_update(&rctx->fallback_req); 146 146 } ··· 152 152 struct rk_ahash_ctx *ctx = crypto_ahash_ctx(tfm); 153 153 154 154 ahash_request_set_tfm(&rctx->fallback_req, ctx->fallback_tfm); 155 - rctx->fallback_req.base.flags = req->base.flags & 156 - CRYPTO_TFM_REQ_MAY_SLEEP; 157 - rctx->fallback_req.result = req->result; 155 + ahash_request_set_callback(&rctx->fallback_req, 156 + req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, 157 + req->base.complete, req->base.data); 158 + ahash_request_set_crypt(&rctx->fallback_req, NULL, req->result, 0); 158 159 159 160 return crypto_ahash_final(&rctx->fallback_req); 160 161 } ··· 167 166 struct rk_ahash_ctx *ctx = crypto_ahash_ctx(tfm); 168 167 169 168 ahash_request_set_tfm(&rctx->fallback_req, ctx->fallback_tfm); 170 - rctx->fallback_req.base.flags = req->base.flags & 171 - CRYPTO_TFM_REQ_MAY_SLEEP; 172 - 173 - rctx->fallback_req.nbytes = req->nbytes; 174 - rctx->fallback_req.src = req->src; 175 - rctx->fallback_req.result = req->result; 169 + ahash_request_set_callback(&rctx->fallback_req, 170 + req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, 171 + req->base.complete, req->base.data); 172 + ahash_request_set_crypt(&rctx->fallback_req, req->src, req->result, 173 + req->nbytes); 176 174 177 175 return crypto_ahash_finup(&rctx->fallback_req); 178 176 } ··· 183 183 struct rk_ahash_ctx *ctx = crypto_ahash_ctx(tfm); 184 184 185 185 ahash_request_set_tfm(&rctx->fallback_req, ctx->fallback_tfm); 186 - rctx->fallback_req.base.flags = req->base.flags & 187 - CRYPTO_TFM_REQ_MAY_SLEEP; 186 + ahash_request_set_callback(&rctx->fallback_req, 187 + req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, 188 + req->base.complete, req->base.data); 188 189 189 190 return crypto_ahash_import(&rctx->fallback_req, in); 190 191 } ··· 197 196 struct rk_ahash_ctx *ctx = crypto_ahash_ctx(tfm); 198 197 199 198 ahash_request_set_tfm(&rctx->fallback_req, ctx->fallback_tfm); 200 - rctx->fallback_req.base.flags = req->base.flags & 201 - CRYPTO_TFM_REQ_MAY_SLEEP; 199 + ahash_request_set_callback(&rctx->fallback_req, 200 + req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, 201 + req->base.complete, req->base.data); 202 202 203 203 return crypto_ahash_export(&rctx->fallback_req, out); 204 204 }