Commit b75fa20c authored by Herbert Xu's avatar Herbert Xu
Browse files

crypto: api - Add crypto_stack_request_init and initialise flags fully



Add a helper to initialise crypto stack requests and use it for
ahash and acomp.  Make sure that the flags field is initialised
fully in the helper to silence false-positive warnings from the
compiler.

Reported-by: default avatarkernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202504250751.mdy28Ibr-lkp@intel.com/


Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent e3b49657
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -547,8 +547,7 @@ static inline struct acomp_req *acomp_request_on_stack_init(
{
	struct acomp_req *req = (void *)buf;

	acomp_request_set_tfm(req, tfm);
	req->base.flags = CRYPTO_TFM_REQ_ON_STACK;
	crypto_stack_request_init(&req->base, crypto_acomp_tfm(tfm));
	return req;
}

+1 −2
Original line number Diff line number Diff line
@@ -1029,8 +1029,7 @@ static inline struct ahash_request *ahash_request_on_stack_init(
{
	struct ahash_request *req = (void *)buf;

	ahash_request_set_tfm(req, tfm);
	req->base.flags = CRYPTO_TFM_REQ_ON_STACK;
	crypto_stack_request_init(&req->base, crypto_ahash_tfm(tfm));
	return req;
}

+2 −2
Original line number Diff line number Diff line
@@ -231,8 +231,8 @@ static inline struct acomp_req *acomp_fbreq_on_stack_init(
	struct crypto_acomp *tfm = crypto_acomp_reqtfm(old);
	struct acomp_req *req = (void *)buf;

	acomp_request_set_tfm(req, crypto_acomp_fb(tfm));
	req->base.flags = CRYPTO_TFM_REQ_ON_STACK;
	crypto_stack_request_init(&req->base,
				  crypto_acomp_tfm(crypto_acomp_fb(tfm)));
	acomp_request_set_callback(req, acomp_request_flags(old), NULL, NULL);
	req->base.flags &= ~CRYPTO_ACOMP_REQ_PRIVATE;
	req->base.flags |= old->base.flags & CRYPTO_ACOMP_REQ_PRIVATE;
+2 −2
Original line number Diff line number Diff line
@@ -283,8 +283,8 @@ static inline struct ahash_request *ahash_fbreq_on_stack_init(
	struct crypto_ahash *tfm = crypto_ahash_reqtfm(old);
	struct ahash_request *req = (void *)buf;

	ahash_request_set_tfm(req, crypto_ahash_fb(tfm));
	req->base.flags = CRYPTO_TFM_REQ_ON_STACK;
	crypto_stack_request_init(&req->base,
				  crypto_ahash_tfm(crypto_ahash_fb(tfm)));
	ahash_request_set_callback(req, ahash_request_flags(old), NULL, NULL);
	req->base.flags &= ~CRYPTO_AHASH_REQ_PRIVATE;
	req->base.flags |= old->base.flags & CRYPTO_AHASH_REQ_PRIVATE;
+8 −0
Original line number Diff line number Diff line
@@ -514,5 +514,13 @@ static inline void crypto_request_set_tfm(struct crypto_async_request *req,
struct crypto_async_request *crypto_request_clone(
	struct crypto_async_request *req, size_t total, gfp_t gfp);

static inline void crypto_stack_request_init(struct crypto_async_request *req,
					     struct crypto_tfm *tfm)
{
	req->flags = 0;
	crypto_request_set_tfm(req, tfm);
	req->flags |= CRYPTO_TFM_REQ_ON_STACK;
}

#endif	/* _LINUX_CRYPTO_H */