mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-08 01:29:02 +00:00
crypto: crypto4xx - fix crypto4xx_build_pdr, crypto4xx_build_sdr leak
commit 5d59ad6eea
upstream.
If one of the later memory allocations in rypto4xx_build_pdr()
fails: dev->pdr (and/or) dev->pdr_uinfo wouldn't be freed.
crypto4xx_build_sdr() has the same issue with dev->sdr.
Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
996a6a393b
commit
03bb918775
1 changed files with 9 additions and 8 deletions
|
@ -240,13 +240,15 @@ static u32 crypto4xx_build_pdr(struct crypto4xx_device *dev)
|
||||||
|
|
||||||
static void crypto4xx_destroy_pdr(struct crypto4xx_device *dev)
|
static void crypto4xx_destroy_pdr(struct crypto4xx_device *dev)
|
||||||
{
|
{
|
||||||
if (dev->pdr != NULL)
|
if (dev->pdr)
|
||||||
dma_free_coherent(dev->core_dev->device,
|
dma_free_coherent(dev->core_dev->device,
|
||||||
sizeof(struct ce_pd) * PPC4XX_NUM_PD,
|
sizeof(struct ce_pd) * PPC4XX_NUM_PD,
|
||||||
dev->pdr, dev->pdr_pa);
|
dev->pdr, dev->pdr_pa);
|
||||||
|
|
||||||
if (dev->shadow_sa_pool)
|
if (dev->shadow_sa_pool)
|
||||||
dma_free_coherent(dev->core_dev->device, 256 * PPC4XX_NUM_PD,
|
dma_free_coherent(dev->core_dev->device, 256 * PPC4XX_NUM_PD,
|
||||||
dev->shadow_sa_pool, dev->shadow_sa_pool_pa);
|
dev->shadow_sa_pool, dev->shadow_sa_pool_pa);
|
||||||
|
|
||||||
if (dev->shadow_sr_pool)
|
if (dev->shadow_sr_pool)
|
||||||
dma_free_coherent(dev->core_dev->device,
|
dma_free_coherent(dev->core_dev->device,
|
||||||
sizeof(struct sa_state_record) * PPC4XX_NUM_PD,
|
sizeof(struct sa_state_record) * PPC4XX_NUM_PD,
|
||||||
|
@ -416,12 +418,12 @@ static u32 crypto4xx_build_sdr(struct crypto4xx_device *dev)
|
||||||
|
|
||||||
static void crypto4xx_destroy_sdr(struct crypto4xx_device *dev)
|
static void crypto4xx_destroy_sdr(struct crypto4xx_device *dev)
|
||||||
{
|
{
|
||||||
if (dev->sdr != NULL)
|
if (dev->sdr)
|
||||||
dma_free_coherent(dev->core_dev->device,
|
dma_free_coherent(dev->core_dev->device,
|
||||||
sizeof(struct ce_sd) * PPC4XX_NUM_SD,
|
sizeof(struct ce_sd) * PPC4XX_NUM_SD,
|
||||||
dev->sdr, dev->sdr_pa);
|
dev->sdr, dev->sdr_pa);
|
||||||
|
|
||||||
if (dev->scatter_buffer_va != NULL)
|
if (dev->scatter_buffer_va)
|
||||||
dma_free_coherent(dev->core_dev->device,
|
dma_free_coherent(dev->core_dev->device,
|
||||||
dev->scatter_buffer_size * PPC4XX_NUM_SD,
|
dev->scatter_buffer_size * PPC4XX_NUM_SD,
|
||||||
dev->scatter_buffer_va,
|
dev->scatter_buffer_va,
|
||||||
|
@ -1191,7 +1193,7 @@ static int crypto4xx_probe(struct platform_device *ofdev)
|
||||||
|
|
||||||
rc = crypto4xx_build_gdr(core_dev->dev);
|
rc = crypto4xx_build_gdr(core_dev->dev);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto err_build_gdr;
|
goto err_build_pdr;
|
||||||
|
|
||||||
rc = crypto4xx_build_sdr(core_dev->dev);
|
rc = crypto4xx_build_sdr(core_dev->dev);
|
||||||
if (rc)
|
if (rc)
|
||||||
|
@ -1234,12 +1236,11 @@ static int crypto4xx_probe(struct platform_device *ofdev)
|
||||||
err_request_irq:
|
err_request_irq:
|
||||||
irq_dispose_mapping(core_dev->irq);
|
irq_dispose_mapping(core_dev->irq);
|
||||||
tasklet_kill(&core_dev->tasklet);
|
tasklet_kill(&core_dev->tasklet);
|
||||||
crypto4xx_destroy_sdr(core_dev->dev);
|
|
||||||
err_build_sdr:
|
err_build_sdr:
|
||||||
|
crypto4xx_destroy_sdr(core_dev->dev);
|
||||||
crypto4xx_destroy_gdr(core_dev->dev);
|
crypto4xx_destroy_gdr(core_dev->dev);
|
||||||
err_build_gdr:
|
|
||||||
crypto4xx_destroy_pdr(core_dev->dev);
|
|
||||||
err_build_pdr:
|
err_build_pdr:
|
||||||
|
crypto4xx_destroy_pdr(core_dev->dev);
|
||||||
kfree(core_dev->dev);
|
kfree(core_dev->dev);
|
||||||
err_alloc_dev:
|
err_alloc_dev:
|
||||||
kfree(core_dev);
|
kfree(core_dev);
|
||||||
|
|
Loading…
Reference in a new issue