@@ -275,8 +275,10 @@ static int tegra_aes_do_one_req(struct crypto_engine *engine, void *areq)
275275 rctx -> datbuf .size = rctx -> len ;
276276 rctx -> datbuf .buf = dma_alloc_coherent (se -> dev , rctx -> datbuf .size ,
277277 & rctx -> datbuf .addr , GFP_KERNEL );
278- if (!rctx -> datbuf .buf )
279- return - ENOMEM ;
278+ if (!rctx -> datbuf .buf ) {
279+ ret = - ENOMEM ;
280+ goto out_finalize ;
281+ }
280282
281283 scatterwalk_map_and_copy (rctx -> datbuf .buf , req -> src , 0 , req -> cryptlen , 0 );
282284
@@ -292,6 +294,7 @@ static int tegra_aes_do_one_req(struct crypto_engine *engine, void *areq)
292294 dma_free_coherent (ctx -> se -> dev , rctx -> datbuf .size ,
293295 rctx -> datbuf .buf , rctx -> datbuf .addr );
294296
297+ out_finalize :
295298 crypto_finalize_skcipher_request (se -> engine , req , ret );
296299
297300 return 0 ;
@@ -1152,21 +1155,21 @@ static int tegra_ccm_do_one_req(struct crypto_engine *engine, void *areq)
11521155
11531156 ret = tegra_ccm_crypt_init (req , se , rctx );
11541157 if (ret )
1155- return ret ;
1158+ goto out_finalize ;
11561159
11571160 /* Allocate buffers required */
11581161 rctx -> inbuf .size = rctx -> assoclen + rctx -> authsize + rctx -> cryptlen + 100 ;
11591162 rctx -> inbuf .buf = dma_alloc_coherent (ctx -> se -> dev , rctx -> inbuf .size ,
11601163 & rctx -> inbuf .addr , GFP_KERNEL );
11611164 if (!rctx -> inbuf .buf )
1162- return - ENOMEM ;
1165+ goto out_finalize ;
11631166
11641167 rctx -> outbuf .size = rctx -> assoclen + rctx -> authsize + rctx -> cryptlen + 100 ;
11651168 rctx -> outbuf .buf = dma_alloc_coherent (ctx -> se -> dev , rctx -> outbuf .size ,
11661169 & rctx -> outbuf .addr , GFP_KERNEL );
11671170 if (!rctx -> outbuf .buf ) {
11681171 ret = - ENOMEM ;
1169- goto outbuf_err ;
1172+ goto out_free_inbuf ;
11701173 }
11711174
11721175 if (rctx -> encrypt ) {
@@ -1195,10 +1198,11 @@ static int tegra_ccm_do_one_req(struct crypto_engine *engine, void *areq)
11951198 dma_free_coherent (ctx -> se -> dev , rctx -> inbuf .size ,
11961199 rctx -> outbuf .buf , rctx -> outbuf .addr );
11971200
1198- outbuf_err :
1201+ out_free_inbuf :
11991202 dma_free_coherent (ctx -> se -> dev , rctx -> outbuf .size ,
12001203 rctx -> inbuf .buf , rctx -> inbuf .addr );
12011204
1205+ out_finalize :
12021206 crypto_finalize_aead_request (ctx -> se -> engine , req , ret );
12031207
12041208 return 0 ;
@@ -1229,15 +1233,17 @@ static int tegra_gcm_do_one_req(struct crypto_engine *engine, void *areq)
12291233 rctx -> inbuf .size = rctx -> assoclen + rctx -> authsize + rctx -> cryptlen ;
12301234 rctx -> inbuf .buf = dma_alloc_coherent (ctx -> se -> dev , rctx -> inbuf .size ,
12311235 & rctx -> inbuf .addr , GFP_KERNEL );
1232- if (!rctx -> inbuf .buf )
1233- return - ENOMEM ;
1236+ if (!rctx -> inbuf .buf ) {
1237+ ret = - ENOMEM ;
1238+ goto out_finalize ;
1239+ }
12341240
12351241 rctx -> outbuf .size = rctx -> assoclen + rctx -> authsize + rctx -> cryptlen ;
12361242 rctx -> outbuf .buf = dma_alloc_coherent (ctx -> se -> dev , rctx -> outbuf .size ,
12371243 & rctx -> outbuf .addr , GFP_KERNEL );
12381244 if (!rctx -> outbuf .buf ) {
12391245 ret = - ENOMEM ;
1240- goto outbuf_err ;
1246+ goto out_free_inbuf ;
12411247 }
12421248
12431249 /* If there is associated data perform GMAC operation */
@@ -1266,11 +1272,11 @@ static int tegra_gcm_do_one_req(struct crypto_engine *engine, void *areq)
12661272 dma_free_coherent (ctx -> se -> dev , rctx -> outbuf .size ,
12671273 rctx -> outbuf .buf , rctx -> outbuf .addr );
12681274
1269- outbuf_err :
1275+ out_free_inbuf :
12701276 dma_free_coherent (ctx -> se -> dev , rctx -> inbuf .size ,
12711277 rctx -> inbuf .buf , rctx -> inbuf .addr );
12721278
1273- /* Finalize the request if there are no errors */
1279+ out_finalize :
12741280 crypto_finalize_aead_request (ctx -> se -> engine , req , ret );
12751281
12761282 return 0 ;
0 commit comments