]> git.karo-electronics.de Git - linux-beck.git/commitdiff
crypto: caam - Move common error handling code in two functions
authorMarkus Elfring <elfring@users.sourceforge.net>
Thu, 15 Sep 2016 14:00:55 +0000 (16:00 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 22 Sep 2016 10:27:46 +0000 (18:27 +0800)
Move statements for error handling which were identical
in two if branches to the end of these functions.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/caam/caamhash.c

index adb8b19ee942d2124e6973ec9874ceae45652162..660dc206969faa509ae8b858d2c2c8296e097d32 100644 (file)
@@ -1231,9 +1231,7 @@ static int ahash_final_no_ctx(struct ahash_request *req)
        state->buf_dma = dma_map_single(jrdev, buf, buflen, DMA_TO_DEVICE);
        if (dma_mapping_error(jrdev, state->buf_dma)) {
                dev_err(jrdev, "unable to map src\n");
-               ahash_unmap(jrdev, edesc, req, digestsize);
-               kfree(edesc);
-               return -ENOMEM;
+               goto unmap;
        }
 
        append_seq_in_ptr(desc, state->buf_dma, buflen, 0);
@@ -1242,9 +1240,7 @@ static int ahash_final_no_ctx(struct ahash_request *req)
                                                digestsize);
        if (dma_mapping_error(jrdev, edesc->dst_dma)) {
                dev_err(jrdev, "unable to map dst\n");
-               ahash_unmap(jrdev, edesc, req, digestsize);
-               kfree(edesc);
-               return -ENOMEM;
+               goto unmap;
        }
        edesc->src_nents = 0;
 
@@ -1262,6 +1258,11 @@ static int ahash_final_no_ctx(struct ahash_request *req)
        }
 
        return ret;
+ unmap:
+       ahash_unmap(jrdev, edesc, req, digestsize);
+       kfree(edesc);
+       return -ENOMEM;
+
 }
 
 /* submit ahash update if it the first job descriptor after update */
@@ -1453,18 +1454,14 @@ static int ahash_finup_no_ctx(struct ahash_request *req)
                                  req->nbytes);
        if (ret) {
                dev_err(jrdev, "unable to map S/G table\n");
-               ahash_unmap(jrdev, edesc, req, digestsize);
-               kfree(edesc);
-               return -ENOMEM;
+               goto unmap;
        }
 
        edesc->dst_dma = map_seq_out_ptr_result(desc, jrdev, req->result,
                                                digestsize);
        if (dma_mapping_error(jrdev, edesc->dst_dma)) {
                dev_err(jrdev, "unable to map dst\n");
-               ahash_unmap(jrdev, edesc, req, digestsize);
-               kfree(edesc);
-               return -ENOMEM;
+               goto unmap;
        }
 
 #ifdef DEBUG
@@ -1481,6 +1478,11 @@ static int ahash_finup_no_ctx(struct ahash_request *req)
        }
 
        return ret;
+ unmap:
+       ahash_unmap(jrdev, edesc, req, digestsize);
+       kfree(edesc);
+       return -ENOMEM;
+
 }
 
 /* submit first update job descriptor after init */