diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-09-21 15:15:37 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-09-21 15:15:37 -0400 |
| commit | 06b050eb81b877c7a4adb6be8624ad3890fee9f2 (patch) | |
| tree | b327d182c6167dcb275ff8d3e46e27df1dad9802 | |
| parent | 633650132e692efe273bf3a4e29411537a5baa86 (diff) | |
| parent | 61c6e7531d3b66b33187b8cdd700fd8ab93ffd62 (diff) | |
Merge branch 'fixes' of git://git.infradead.org/users/vkoul/slave-dma
Pull slave-dmaengine fixes from Vinod Koul:
"There are two trivial fixes in pl330 driver and two in at_hdmac
driver."
* 'fixes' of git://git.infradead.org/users/vkoul/slave-dma:
DMA: PL330: Check the pointer returned by kzalloc
DMA: PL330: Fix potential NULL pointer dereference in pl330_submit_req()
dmaengine: at_hdmac: check that each sg data length is non-null
dmaengine: at_hdmac: fix comment in atc_prep_slave_sg()
| -rw-r--r-- | drivers/dma/at_hdmac.c | 13 | ||||
| -rw-r--r-- | drivers/dma/pl330.c | 21 |
2 files changed, 26 insertions, 8 deletions
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c index 3934fcc4e00b..7ab6e26664a7 100644 --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c | |||
| @@ -661,7 +661,7 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, | |||
| 661 | flags); | 661 | flags); |
| 662 | 662 | ||
| 663 | if (unlikely(!atslave || !sg_len)) { | 663 | if (unlikely(!atslave || !sg_len)) { |
| 664 | dev_dbg(chan2dev(chan), "prep_dma_memcpy: length is zero!\n"); | 664 | dev_dbg(chan2dev(chan), "prep_slave_sg: sg length is zero!\n"); |
| 665 | return NULL; | 665 | return NULL; |
| 666 | } | 666 | } |
| 667 | 667 | ||
| @@ -689,6 +689,11 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, | |||
| 689 | 689 | ||
| 690 | mem = sg_dma_address(sg); | 690 | mem = sg_dma_address(sg); |
| 691 | len = sg_dma_len(sg); | 691 | len = sg_dma_len(sg); |
| 692 | if (unlikely(!len)) { | ||
| 693 | dev_dbg(chan2dev(chan), | ||
| 694 | "prep_slave_sg: sg(%d) data length is zero\n", i); | ||
| 695 | goto err; | ||
| 696 | } | ||
| 692 | mem_width = 2; | 697 | mem_width = 2; |
| 693 | if (unlikely(mem & 3 || len & 3)) | 698 | if (unlikely(mem & 3 || len & 3)) |
| 694 | mem_width = 0; | 699 | mem_width = 0; |
| @@ -724,6 +729,11 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, | |||
| 724 | 729 | ||
| 725 | mem = sg_dma_address(sg); | 730 | mem = sg_dma_address(sg); |
| 726 | len = sg_dma_len(sg); | 731 | len = sg_dma_len(sg); |
| 732 | if (unlikely(!len)) { | ||
| 733 | dev_dbg(chan2dev(chan), | ||
| 734 | "prep_slave_sg: sg(%d) data length is zero\n", i); | ||
| 735 | goto err; | ||
| 736 | } | ||
| 727 | mem_width = 2; | 737 | mem_width = 2; |
| 728 | if (unlikely(mem & 3 || len & 3)) | 738 | if (unlikely(mem & 3 || len & 3)) |
| 729 | mem_width = 0; | 739 | mem_width = 0; |
| @@ -757,6 +767,7 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, | |||
| 757 | 767 | ||
| 758 | err_desc_get: | 768 | err_desc_get: |
| 759 | dev_err(chan2dev(chan), "not enough descriptors available\n"); | 769 | dev_err(chan2dev(chan), "not enough descriptors available\n"); |
| 770 | err: | ||
| 760 | atc_desc_put(atchan, first); | 771 | atc_desc_put(atchan, first); |
| 761 | return NULL; | 772 | return NULL; |
| 762 | } | 773 | } |
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index e4feba6b03c0..f5843bc80baa 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c | |||
| @@ -1567,17 +1567,19 @@ static int pl330_submit_req(void *ch_id, struct pl330_req *r) | |||
| 1567 | goto xfer_exit; | 1567 | goto xfer_exit; |
| 1568 | } | 1568 | } |
| 1569 | 1569 | ||
| 1570 | /* Prefer Secure Channel */ | ||
| 1571 | if (!_manager_ns(thrd)) | ||
| 1572 | r->cfg->nonsecure = 0; | ||
| 1573 | else | ||
| 1574 | r->cfg->nonsecure = 1; | ||
| 1575 | 1570 | ||
| 1576 | /* Use last settings, if not provided */ | 1571 | /* Use last settings, if not provided */ |
| 1577 | if (r->cfg) | 1572 | if (r->cfg) { |
| 1573 | /* Prefer Secure Channel */ | ||
| 1574 | if (!_manager_ns(thrd)) | ||
| 1575 | r->cfg->nonsecure = 0; | ||
| 1576 | else | ||
| 1577 | r->cfg->nonsecure = 1; | ||
| 1578 | |||
| 1578 | ccr = _prepare_ccr(r->cfg); | 1579 | ccr = _prepare_ccr(r->cfg); |
| 1579 | else | 1580 | } else { |
| 1580 | ccr = readl(regs + CC(thrd->id)); | 1581 | ccr = readl(regs + CC(thrd->id)); |
| 1582 | } | ||
| 1581 | 1583 | ||
| 1582 | /* If this req doesn't have valid xfer settings */ | 1584 | /* If this req doesn't have valid xfer settings */ |
| 1583 | if (!_is_valid(ccr)) { | 1585 | if (!_is_valid(ccr)) { |
| @@ -2928,6 +2930,11 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) | |||
| 2928 | num_chan = max_t(int, pi->pcfg.num_peri, pi->pcfg.num_chan); | 2930 | num_chan = max_t(int, pi->pcfg.num_peri, pi->pcfg.num_chan); |
| 2929 | 2931 | ||
| 2930 | pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL); | 2932 | pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL); |
| 2933 | if (!pdmac->peripherals) { | ||
| 2934 | ret = -ENOMEM; | ||
| 2935 | dev_err(&adev->dev, "unable to allocate pdmac->peripherals\n"); | ||
| 2936 | goto probe_err5; | ||
| 2937 | } | ||
| 2931 | 2938 | ||
| 2932 | for (i = 0; i < num_chan; i++) { | 2939 | for (i = 0; i < num_chan; i++) { |
| 2933 | pch = &pdmac->peripherals[i]; | 2940 | pch = &pdmac->peripherals[i]; |
