Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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()

+26 -8
+12 -1
drivers/dma/at_hdmac.c
··· 661 661 flags); 662 662 663 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 665 return NULL; 666 666 } 667 667 ··· 689 689 690 690 mem = sg_dma_address(sg); 691 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 697 mem_width = 2; 693 698 if (unlikely(mem & 3 || len & 3)) 694 699 mem_width = 0; ··· 729 724 730 725 mem = sg_dma_address(sg); 731 726 len = sg_dma_len(sg); 727 + if (unlikely(!len)) { 728 + dev_dbg(chan2dev(chan), 729 + "prep_slave_sg: sg(%d) data length is zero\n", i); 730 + goto err; 731 + } 732 732 mem_width = 2; 733 733 if (unlikely(mem & 3 || len & 3)) 734 734 mem_width = 0; ··· 767 757 768 758 err_desc_get: 769 759 dev_err(chan2dev(chan), "not enough descriptors available\n"); 760 + err: 770 761 atc_desc_put(atchan, first); 771 762 return NULL; 772 763 }
+14 -7
drivers/dma/pl330.c
··· 1567 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 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 1579 ccr = _prepare_ccr(r->cfg); 1579 - else 1580 + } else { 1580 1581 ccr = readl(regs + CC(thrd->id)); 1582 + } 1581 1583 1582 1584 /* If this req doesn't have valid xfer settings */ 1583 1585 if (!_is_valid(ccr)) { ··· 2930 2928 num_chan = max_t(int, pi->pcfg.num_peri, pi->pcfg.num_chan); 2931 2929 2932 2930 pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL); 2931 + if (!pdmac->peripherals) { 2932 + ret = -ENOMEM; 2933 + dev_err(&adev->dev, "unable to allocate pdmac->peripherals\n"); 2934 + goto probe_err5; 2935 + } 2933 2936 2934 2937 for (i = 0; i < num_chan; i++) { 2935 2938 pch = &pdmac->peripherals[i];