crypto: atmel - Free memory in error path
authorChristophe Jaillet <christophe.jaillet@wanadoo.fr>
Tue, 20 Jan 2015 07:15:52 +0000 (08:15 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 26 Jan 2015 00:34:21 +0000 (11:34 +1100)
If only one of the 2 __get_free_pages fails, then there is a memory leak.

Signed-off-by: Christophe Jaillet <christophe.jaillet@wanadoo.fr>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/atmel-aes.c
drivers/crypto/atmel-tdes.c

index 53d1c330f8a82d5cffddeaedeb896d8d300bd7d3..6597aac9905d1d7aae890b952f30f4cb7aad6e70 100644 (file)
@@ -673,9 +673,9 @@ err_map_out:
        dma_unmap_single(dd->dev, dd->dma_addr_in, dd->buflen,
                DMA_TO_DEVICE);
 err_map_in:
+err_alloc:
        free_page((unsigned long)dd->buf_out);
        free_page((unsigned long)dd->buf_in);
-err_alloc:
        if (err)
                pr_err("error: %d\n", err);
        return err;
index 5e7c896cde307cd791c14a6903f1fbf5c639ab1c..258772d9b22f3fa979247af67b92383ae6c7e356 100644 (file)
@@ -376,9 +376,9 @@ err_map_out:
        dma_unmap_single(dd->dev, dd->dma_addr_in, dd->buflen,
                DMA_TO_DEVICE);
 err_map_in:
+err_alloc:
        free_page((unsigned long)dd->buf_out);
        free_page((unsigned long)dd->buf_in);
-err_alloc:
        if (err)
                pr_err("error: %d\n", err);
        return err;