lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220526135111.1470926-1-michael@walle.cc>
Date:   Thu, 26 May 2022 15:51:11 +0200
From:   Michael Walle <michael@...le.cc>
To:     Ludovic Desroches <ludovic.desroches@...rochip.com>,
        Tudor Ambarus <tudor.ambarus@...rochip.com>,
        Vinod Koul <vkoul@...nel.org>,
        Nicolas Ferre <nicolas.ferre@...rochip.com>
Cc:     linux-arm-kernel@...ts.infradead.org, dmaengine@...r.kernel.org,
        linux-kernel@...r.kernel.org, Michael Walle <michael@...le.cc>
Subject: [PATCH] dmaengine: at_xdma: handle errors of at_xdmac_alloc_desc() correctly

It seems that it is valid to have less than the requested number of
descriptors. But what is not valid and leads to subsequent errors is to
have zero descriptors. In that case, abort the probing.

Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver")
Signed-off-by: Michael Walle <michael@...le.cc>
---
This was noticed with the atmel i2c driver:

[    2.488878] cma: cma_alloc: reserved: alloc failed, req-size: 1 pages, ret: -16
[    2.488934] dma dma0chan0: only 0 descriptors have been allocated
[    2.558378] cma: cma_alloc: reserved: alloc failed, req-size: 1 pages, ret: -16
[    2.558428] dma dma0chan1: only 0 descriptors have been allocated
[    2.558509] at91_i2c e0070600.i2c: using dma0chan0 (tx) and dma0chan1 (rx) for DMA transfers
[    2.558906] at91_i2c e0070600.i2c: AT91 i2c bus driver (hw version: 0x820).
..
[    7.393971] ------------[ cut here ]------------
[    7.393998] WARNING: CPU: 0 PID: 48 at arch/arm/mm/dma-mapping.c:492 pool_allocator_alloc+0xa0/0xa4
[    7.404940] coherent pool not initialised!
[    7.409018] Modules linked in:
[    7.412060] CPU: 0 PID: 48 Comm: kworker/0:6 Not tainted 5.18.0-next-20220526+ #639
[    7.419694] Hardware name: Generic DT based system
[    7.424472] Workqueue: events_power_efficient sfp_timeout
..
[    7.755103] dma dma0chan1: can't get descriptor
[    7.755239] at91_i2c e0070600.i2c: dma prep slave sg failed
[    8.133324] at91_i2c e0070600.i2c: controller timed out

Please note that this doesn't fix the underlying problem. It will just
handle that one gracefully.

 drivers/dma/at_xdmac.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
index 3e9d726504e2..7b3e6030f7b4 100644
--- a/drivers/dma/at_xdmac.c
+++ b/drivers/dma/at_xdmac.c
@@ -1900,6 +1900,11 @@ static int at_xdmac_alloc_chan_resources(struct dma_chan *chan)
 	for (i = 0; i < init_nr_desc_per_channel; i++) {
 		desc = at_xdmac_alloc_desc(chan, GFP_KERNEL);
 		if (!desc) {
+			if (i == 0) {
+				dev_warn(chan2dev(chan),
+					 "can't allocate any descriptors\n");
+				return -EIO;
+			}
 			dev_warn(chan2dev(chan),
 				"only %d descriptors have been allocated\n", i);
 			break;
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ