Commit 06b050eb authored by Linus Torvalds's avatar Linus Torvalds

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()
parents 63365013 61c6e753
...@@ -661,7 +661,7 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, ...@@ -661,7 +661,7 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
flags); flags);
if (unlikely(!atslave || !sg_len)) { if (unlikely(!atslave || !sg_len)) {
dev_dbg(chan2dev(chan), "prep_dma_memcpy: length is zero!\n"); dev_dbg(chan2dev(chan), "prep_slave_sg: sg length is zero!\n");
return NULL; return NULL;
} }
...@@ -689,6 +689,11 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, ...@@ -689,6 +689,11 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
mem = sg_dma_address(sg); mem = sg_dma_address(sg);
len = sg_dma_len(sg); len = sg_dma_len(sg);
if (unlikely(!len)) {
dev_dbg(chan2dev(chan),
"prep_slave_sg: sg(%d) data length is zero\n", i);
goto err;
}
mem_width = 2; mem_width = 2;
if (unlikely(mem & 3 || len & 3)) if (unlikely(mem & 3 || len & 3))
mem_width = 0; mem_width = 0;
...@@ -724,6 +729,11 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, ...@@ -724,6 +729,11 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
mem = sg_dma_address(sg); mem = sg_dma_address(sg);
len = sg_dma_len(sg); len = sg_dma_len(sg);
if (unlikely(!len)) {
dev_dbg(chan2dev(chan),
"prep_slave_sg: sg(%d) data length is zero\n", i);
goto err;
}
mem_width = 2; mem_width = 2;
if (unlikely(mem & 3 || len & 3)) if (unlikely(mem & 3 || len & 3))
mem_width = 0; mem_width = 0;
...@@ -757,6 +767,7 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, ...@@ -757,6 +767,7 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
err_desc_get: err_desc_get:
dev_err(chan2dev(chan), "not enough descriptors available\n"); dev_err(chan2dev(chan), "not enough descriptors available\n");
err:
atc_desc_put(atchan, first); atc_desc_put(atchan, first);
return NULL; return NULL;
} }
......
...@@ -1567,17 +1567,19 @@ static int pl330_submit_req(void *ch_id, struct pl330_req *r) ...@@ -1567,17 +1567,19 @@ static int pl330_submit_req(void *ch_id, struct pl330_req *r)
goto xfer_exit; goto xfer_exit;
} }
/* Prefer Secure Channel */
if (!_manager_ns(thrd))
r->cfg->nonsecure = 0;
else
r->cfg->nonsecure = 1;
/* Use last settings, if not provided */ /* Use last settings, if not provided */
if (r->cfg) if (r->cfg) {
/* Prefer Secure Channel */
if (!_manager_ns(thrd))
r->cfg->nonsecure = 0;
else
r->cfg->nonsecure = 1;
ccr = _prepare_ccr(r->cfg); ccr = _prepare_ccr(r->cfg);
else } else {
ccr = readl(regs + CC(thrd->id)); ccr = readl(regs + CC(thrd->id));
}
/* If this req doesn't have valid xfer settings */ /* If this req doesn't have valid xfer settings */
if (!_is_valid(ccr)) { if (!_is_valid(ccr)) {
...@@ -2928,6 +2930,11 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2928,6 +2930,11 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
num_chan = max_t(int, pi->pcfg.num_peri, pi->pcfg.num_chan); num_chan = max_t(int, pi->pcfg.num_peri, pi->pcfg.num_chan);
pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL); pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL);
if (!pdmac->peripherals) {
ret = -ENOMEM;
dev_err(&adev->dev, "unable to allocate pdmac->peripherals\n");
goto probe_err5;
}
for (i = 0; i < num_chan; i++) { for (i = 0; i < num_chan; i++) {
pch = &pdmac->peripherals[i]; pch = &pdmac->peripherals[i];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment