@@ -147,7 +147,6 @@ struct omap_sham_reqctx {
147147 u8 digest [SHA512_DIGEST_SIZE ] OMAP_ALIGNED ;
148148 size_t digcnt ;
149149 size_t bufcnt ;
150- size_t buflen ;
151150
152151 /* walk state */
153152 struct scatterlist * sg ;
@@ -156,7 +155,7 @@ struct omap_sham_reqctx {
156155 int sg_len ;
157156 unsigned int total ; /* total request */
158157
159- u8 buffer [] OMAP_ALIGNED ;
158+ u8 buffer [BUFLEN ] OMAP_ALIGNED ;
160159};
161160
162161struct omap_sham_hmac_ctx {
@@ -891,7 +890,7 @@ static int omap_sham_prepare_request(struct crypto_engine *engine, void *areq)
891890 if (hash_later < 0 )
892891 hash_later = 0 ;
893892
894- if (hash_later && hash_later <= rctx -> buflen ) {
893+ if (hash_later && hash_later <= sizeof ( rctx -> buffer ) ) {
895894 scatterwalk_map_and_copy (rctx -> buffer ,
896895 req -> src ,
897896 req -> nbytes - hash_later ,
@@ -902,7 +901,7 @@ static int omap_sham_prepare_request(struct crypto_engine *engine, void *areq)
902901 rctx -> bufcnt = 0 ;
903902 }
904903
905- if (hash_later > rctx -> buflen )
904+ if (hash_later > sizeof ( rctx -> buffer ) )
906905 set_bit (FLAGS_HUGE , & rctx -> dd -> flags );
907906
908907 rctx -> total = min (nbytes , rctx -> total );
@@ -987,7 +986,6 @@ static int omap_sham_init(struct ahash_request *req)
987986 ctx -> digcnt = 0 ;
988987 ctx -> total = 0 ;
989988 ctx -> offset = 0 ;
990- ctx -> buflen = BUFLEN ;
991989
992990 if (tctx -> flags & BIT (FLAGS_HMAC )) {
993991 if (!test_bit (FLAGS_AUTO_XOR , & dd -> flags )) {
@@ -1200,7 +1198,7 @@ static int omap_sham_update(struct ahash_request *req)
12001198 if (!req -> nbytes )
12011199 return 0 ;
12021200
1203- if (ctx -> bufcnt + req -> nbytes <= ctx -> buflen ) {
1201+ if (ctx -> bufcnt + req -> nbytes <= sizeof ( ctx -> buffer ) ) {
12041202 scatterwalk_map_and_copy (ctx -> buffer + ctx -> bufcnt , req -> src ,
12051203 0 , req -> nbytes , 0 );
12061204 ctx -> bufcnt += req -> nbytes ;
@@ -1333,7 +1331,7 @@ static int omap_sham_cra_init_alg(struct crypto_tfm *tfm, const char *alg_base)
13331331 }
13341332
13351333 crypto_ahash_set_reqsize (__crypto_ahash_cast (tfm ),
1336- sizeof (struct omap_sham_reqctx ) + BUFLEN );
1334+ sizeof (struct omap_sham_reqctx ));
13371335
13381336 if (alg_base ) {
13391337 struct omap_sham_hmac_ctx * bctx = tctx -> base ;
@@ -1404,7 +1402,8 @@ static int omap_sham_export(struct ahash_request *req, void *out)
14041402{
14051403 struct omap_sham_reqctx * rctx = ahash_request_ctx (req );
14061404
1407- memcpy (out , rctx , sizeof (* rctx ) + rctx -> bufcnt );
1405+ memcpy (out , rctx , offsetof(struct omap_sham_reqctx , buffer ) +
1406+ rctx -> bufcnt );
14081407
14091408 return 0 ;
14101409}
@@ -1414,7 +1413,8 @@ static int omap_sham_import(struct ahash_request *req, const void *in)
14141413 struct omap_sham_reqctx * rctx = ahash_request_ctx (req );
14151414 const struct omap_sham_reqctx * ctx_in = in ;
14161415
1417- memcpy (rctx , in , sizeof (* rctx ) + ctx_in -> bufcnt );
1416+ memcpy (rctx , in , offsetof(struct omap_sham_reqctx , buffer ) +
1417+ ctx_in -> bufcnt );
14181418
14191419 return 0 ;
14201420}
@@ -2146,8 +2146,7 @@ static int omap_sham_probe(struct platform_device *pdev)
21462146 alg = & ealg -> base ;
21472147 alg -> export = omap_sham_export ;
21482148 alg -> import = omap_sham_import ;
2149- alg -> halg .statesize = sizeof (struct omap_sham_reqctx ) +
2150- BUFLEN ;
2149+ alg -> halg .statesize = sizeof (struct omap_sham_reqctx );
21512150 err = crypto_engine_register_ahash (ealg );
21522151 if (err )
21532152 goto err_algs ;
0 commit comments