diff options
| author | Cristian Stoica <cristian.stoica@freescale.com> | 2015-01-22 09:00:49 -0500 |
|---|---|---|
| committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-01-25 19:34:25 -0500 |
| commit | cbceeefd872480afe46197633826a424196d8131 (patch) | |
| tree | 3fade323be783fa415edfcf1468fc2f17a5a76c6 /drivers/crypto/caam | |
| parent | c6bf62e4f34f0f490ecbba184e57a8c6808b3cb1 (diff) | |
crypto: caam - fix resource clean-up on error path for caam_jr_init
Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/caam')
| -rw-r--r-- | drivers/crypto/caam/jr.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index bce2959993eb..b8b5d47acd7a 100644 --- a/drivers/crypto/caam/jr.c +++ b/drivers/crypto/caam/jr.c | |||
| @@ -384,28 +384,28 @@ static int caam_jr_init(struct device *dev) | |||
| 384 | if (error) { | 384 | if (error) { |
| 385 | dev_err(dev, "can't connect JobR %d interrupt (%d)\n", | 385 | dev_err(dev, "can't connect JobR %d interrupt (%d)\n", |
| 386 | jrp->ridx, jrp->irq); | 386 | jrp->ridx, jrp->irq); |
| 387 | return -EINVAL; | 387 | goto out_kill_deq; |
| 388 | } | 388 | } |
| 389 | 389 | ||
| 390 | error = caam_reset_hw_jr(dev); | 390 | error = caam_reset_hw_jr(dev); |
| 391 | if (error) | 391 | if (error) |
| 392 | return error; | 392 | goto out_free_irq; |
| 393 | 393 | ||
| 394 | error = -ENOMEM; | ||
| 394 | jrp->inpring = dma_alloc_coherent(dev, sizeof(dma_addr_t) * JOBR_DEPTH, | 395 | jrp->inpring = dma_alloc_coherent(dev, sizeof(dma_addr_t) * JOBR_DEPTH, |
| 395 | &inpbusaddr, GFP_KERNEL); | 396 | &inpbusaddr, GFP_KERNEL); |
| 397 | if (!jrp->inpring) | ||
| 398 | goto out_free_irq; | ||
| 396 | 399 | ||
| 397 | jrp->outring = dma_alloc_coherent(dev, sizeof(struct jr_outentry) * | 400 | jrp->outring = dma_alloc_coherent(dev, sizeof(struct jr_outentry) * |
| 398 | JOBR_DEPTH, &outbusaddr, GFP_KERNEL); | 401 | JOBR_DEPTH, &outbusaddr, GFP_KERNEL); |
| 402 | if (!jrp->outring) | ||
| 403 | goto out_free_inpring; | ||
| 399 | 404 | ||
| 400 | jrp->entinfo = kzalloc(sizeof(struct caam_jrentry_info) * JOBR_DEPTH, | 405 | jrp->entinfo = kzalloc(sizeof(struct caam_jrentry_info) * JOBR_DEPTH, |
| 401 | GFP_KERNEL); | 406 | GFP_KERNEL); |
| 402 | 407 | if (!jrp->entinfo) | |
| 403 | if ((jrp->inpring == NULL) || (jrp->outring == NULL) || | 408 | goto out_free_outring; |
| 404 | (jrp->entinfo == NULL)) { | ||
| 405 | dev_err(dev, "can't allocate job rings for %d\n", | ||
| 406 | jrp->ridx); | ||
| 407 | return -ENOMEM; | ||
| 408 | } | ||
| 409 | 409 | ||
| 410 | for (i = 0; i < JOBR_DEPTH; i++) | 410 | for (i = 0; i < JOBR_DEPTH; i++) |
| 411 | jrp->entinfo[i].desc_addr_dma = !0; | 411 | jrp->entinfo[i].desc_addr_dma = !0; |
| @@ -432,6 +432,19 @@ static int caam_jr_init(struct device *dev) | |||
| 432 | (JOBR_INTC_TIME_THLD << JRCFG_ICTT_SHIFT)); | 432 | (JOBR_INTC_TIME_THLD << JRCFG_ICTT_SHIFT)); |
| 433 | 433 | ||
| 434 | return 0; | 434 | return 0; |
| 435 | |||
| 436 | out_free_outring: | ||
| 437 | dma_free_coherent(dev, sizeof(struct jr_outentry) * JOBR_DEPTH, | ||
| 438 | jrp->outring, outbusaddr); | ||
| 439 | out_free_inpring: | ||
| 440 | dma_free_coherent(dev, sizeof(dma_addr_t) * JOBR_DEPTH, | ||
| 441 | jrp->inpring, inpbusaddr); | ||
| 442 | dev_err(dev, "can't allocate job rings for %d\n", jrp->ridx); | ||
| 443 | out_free_irq: | ||
| 444 | free_irq(jrp->irq, dev); | ||
| 445 | out_kill_deq: | ||
| 446 | tasklet_kill(&jrp->irqtask); | ||
| 447 | return error; | ||
| 435 | } | 448 | } |
| 436 | 449 | ||
| 437 | 450 | ||
