Commit ab300465676b0c0559af62d57ec9a902f5680b03
1 parent
0b767b4df3
Exists in
master
and in
4 other branches
crypto: api - Fix aligned ctx helper
The aligned ctx helper was using a bogus alignment value thas was one off the correct value. Fortunately the current users do not require anything beyond the natural alignment of the platform so this hasn't caused a problem. This patch fixes that and also removes the unnecessary minimum check since if the alignment is less than the natural alignment then the subsequent ALIGN operation should be a noop. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Showing 1 changed file with 2 additions and 6 deletions Side-by-side Diff
include/crypto/algapi.h
... | ... | @@ -175,12 +175,8 @@ |
175 | 175 | |
176 | 176 | static inline void *crypto_tfm_ctx_aligned(struct crypto_tfm *tfm) |
177 | 177 | { |
178 | - unsigned long addr = (unsigned long)crypto_tfm_ctx(tfm); | |
179 | - unsigned long align = crypto_tfm_alg_alignmask(tfm); | |
180 | - | |
181 | - if (align <= crypto_tfm_ctx_alignment()) | |
182 | - align = 1; | |
183 | - return (void *)ALIGN(addr, align); | |
178 | + return PTR_ALIGN(crypto_tfm_ctx(tfm), | |
179 | + crypto_tfm_alg_alignmask(tfm) + 1); | |
184 | 180 | } |
185 | 181 | |
186 | 182 | static inline struct crypto_instance *crypto_tfm_alg_instance( |