dmaengine: atcdmac300: Add Andes ATCDMAC300 DMA driver
Subsystems (2)
v5 cover dmaengine: atcdmac300: Add Andes ATCDMAC300 DMA driver
This patch series adds support for the Andes ATCDMAC300 DMA controller, a memory-to-memory and peripheral DMA controller that provides scatter-gather, cyclic, and slave transfer capabilities.
The ATCDMAC300 IP is embedded in AndesCore-based platforms or SoCs such as AE350 and Qilai.
Changes in v5:
- Update copyright year to 2026
- Remove redundant headers (init.h, iopoll.h, mod_devicetable.h)
- Move atcdmac_init_iocp() before of_dma_controller_register() in probe
- Change builtin_platform_driver() to module_platform_driver()
- Implement .remove callback to support safe module unloading
- Update Kconfig entry from bool to tristate
- Add MODULE_AUTHOR, MODULE_DESCRIPTION, MODULE_LICENSE macros
Changes in v4:
- Use items list format with descriptions for reg property in DT binding as suggested by Conor Dooley
- Re-add Acked-by from Conor Dooley for DT binding patch
Changes in v3:
- Rename DT binding file from andestech,qilai-dma.yaml to andestech,ae350-dma.yaml
- Deprecate IP-core-based compatible usage and align with SoC/platform-based strings
- Dropped Acked-by from Conor Dooley due to the above binding change
- Remove "andestech,atcdmac300" from of_device_id table
- Replace deprecated tasklet with threaded IRQ using devm_request_threaded_irq() and IRQF_ONESHOT
- Update locking from spin_lock_bh() to spin_lock_irqsave()
- Use builtin_platform_driver() instead of module_platform_driver()
- Remove "select DMATEST" from Kconfig
- Add separate MAINTAINERS patch (patch 3/3)
Please kindly review.
CL Wang (3):
dt-bindings: dmaengine: Add support for ATCDMAC300 DMA engine
dmaengine: atcdmac300: Add driver for Andes ATCDMAC300 DMA controller
MAINTAINERS: Add entry for Andes ATCDMAC300
.../bindings/dma/andestech,ae350-dma.yaml | 67 + MAINTAINERS | 6 + drivers/dma/Kconfig | 11 + drivers/dma/Makefile | 1 + drivers/dma/atcdmac300.c | 1518 +++++++++++++++++ drivers/dma/atcdmac300.h | 296 ++++ 6 files changed, 1899 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/andestech,ae350-dma.yaml create mode 100644 drivers/dma/atcdmac300.c create mode 100644 drivers/dma/atcdmac300.h
Signature · 1 line
2.34.1
PATCH v5 1/3 dt-bindings: dmaengine: Add support for ATCDMAC300 DMA engine
Document devicetree bindings for Andes ATCDMAC300 DMA engine
ATCDMAC300 is the IP name, which is embedded in AndesCore-based platforms or SoCs such as AE350 and Qilai.
---
Changes for v5:
- No changes from v4
Changes for v4:
- Use items list format with descriptions for reg property as suggested by Conor Dooley
Changes for v3:
- Rename DT binding file from andestech,qilai-dma.yaml to andestech,ae350-dma.yaml.
- Deprecate IP-core-based compatible usage and align with SoC/platform-based strings.
- Dropped Acked-by tag from Conor Dooley due to the above change.
--- .../bindings/dma/andestech,ae350-dma.yaml | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/andestech,ae350-dma.yaml
Documentation/devicetree/bindings/dma/andestech,ae350-dma.yaml new file +67 -0
@@ -0,0 +1,67 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/dma/andestech,ae350-dma.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Andes ATCDMAC300 DMA Controller + +maintainers: + - CL Wang <[email protected]> + +allOf: + - $ref: dma-controller.yaml# + +properties: + compatible: + oneOf: + - items: + - enum: + - andestech,qilai-dma + - const: andestech,ae350-dma + - const: andestech,ae350-dma + + reg: + minItems: 1 + items: + - description: DMA controller register range + - description: cache control in IOCP controller + + reg-names: + minItems: 1 + items: + - const: dma + - const: iocp + + interrupts: + maxItems: 1 + + "#dma-cells": + const: 1 + +required: + - compatible + - reg + - interrupts + - "#dma-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + dma-controller@f0c00000 { + compatible = "andestech,ae350-dma"; + reg = <0x0 0xf0c00000 0x0 0x1000>, + <0x0 0xe8000000 0x0 0x10>; + reg-names = "dma", "iocp"; + interrupts = <10 IRQ_TYPE_LEVEL_HIGH>; + #dma-cells = <1>; + }; + }; +...
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v5 1/3] dt-bindings: dmaengine: Add support for ATCDMAC300 DMA engine
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The schema uses `additionalProperties: false` instead of `unevaluatedProperties: false` while…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The schema uses additionalProperties: false instead of unevaluatedProperties: false while referencing a common subsystem schema. --
commit 0c4fc28dab967baedae4dfdcb32dfa0eb77d45a5
Author: CL Wang <[email protected]>
dt-bindings: dmaengine: Add support for ATCDMAC300 DMA engine
This commit documents devicetree bindings for the Andes ATCDMAC300 DMA engine, which is embedded in AndesCore-based platforms such as AE350 and Qilai.
Quoted 5 lines
Documentation/devicetree/bindings/dma/andestech,ae350-dma.yaml new file +0
-0
[ ... ]
Quoted 2 lines
Documentation/devicetree/bindings/dma/andestech,ae350-dma.yaml new file +2
-0+allOf: + - $ref: dma-controller.yaml#
[ ... ]
Documentation/devicetree/bindings/dma/andestech,ae350-dma.yaml line 48
Quoted 7 lines
Documentation/devicetree/bindings/dma/andestech,ae350-dma.yaml new file +7
-0+required: + - compatible + - reg + - interrupts + - "#dma-cells" + +additionalProperties: false
[Severity: Low]
Does using additionalProperties: false here prevent the use of common DMA properties defined in dma-controller.yaml (like dma-channels or dma-requests)?
Since this binding includes another schema under allOf, should it use
unevaluatedProperties: false instead, so that dt-validate correctly evaluates and permits those inherited properties?
Quoted 3 lines
Documentation/devicetree/bindings/dma/andestech,ae350-dma.yaml new file +3
-0+ +examples: + - |
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v5 2/3 dmaengine: atcdmac300: Add driver for Andes ATCDMAC300 DMA controller
In reply to CL WangThis patch adds support for the Andes ATCDMAC300 DMA controller.
The ATCDMAC300 is a memory-to-memory and peripheral DMA controller that provides scatter-gather, cyclic, and slave transfer capabilities.
---
Changes for v5:
- Update copyright year to 2026
- Remove redundant headers (init.h, iopoll.h, mod_devicetable.h)
- Move atcdmac_init_iocp() before of_dma_controller_register() in probe
- Change builtin_platform_driver() to module_platform_driver()
- Implement .remove callback to support safe module unloading
- Update Kconfig entry from bool to tristate
- Add MODULE_AUTHOR, MODULE_DESCRIPTION, MODULE_LICENSE macros
Changes for v4:
- No changes from v3
Changes for v3:
- Remove "andestech,atcdmac300" from of_device_id
- Replace deprecated tasklet with threaded IRQ using devm_request_threaded_irq() and IRQF_ONESHOT to handle bottom-half processing.
- Update locking mechanism from spin_lock_bh() to spin_lock_irqsave()
- Minor cleanups and correctness fixes
- Initialize descriptor pointers (first = NULL) explicitly
- Add missing headers (err.h, iopoll.h, log2.h, sprintf.h)
- Remove unused code paths related to tasklets
- Use builtin_platform_driver() instead of module_platform_driver()
- Remove "select DMATEST" from Kconfig
--- drivers/dma/Kconfig | 11 + drivers/dma/Makefile | 1 + drivers/dma/atcdmac300.c | 1518 ++++++++++++++++++++++++++++++++++++++ drivers/dma/atcdmac300.h | 296 ++++++++ 4 files changed, 1826 insertions(+) create mode 100644 drivers/dma/atcdmac300.c create mode 100644 drivers/dma/atcdmac300.h
drivers/dma/Kconfig +11 -0
@@ -100,6 +100,17 @@ config ARM_DMA350 help Enable support for the Arm DMA-350 controller. +config ATCDMAC300 + tristate "Andes ATCDMAC300 DMA support" + depends on ARCH_ANDES + depends on OF + select DMA_ENGINE + help + Enable support for the Andes ATCDMAC300 DMA controller. + Select Y or M if your platform includes an ATCDMAC300 device that + requires DMA engine support. This driver supports DMA_SLAVE, + DMA_MEMCPY, and DMA_CYCLIC transfer modes. + config AT_HDMAC tristate "Atmel AHB DMA support" depends on ARCH_AT91 || COMPILE_TEST
drivers/dma/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-$(CONFIG_AMBA_PL08X) += amba-pl08x.o obj-$(CONFIG_AMCC_PPC440SPE_ADMA) += ppc4xx/ obj-$(CONFIG_APPLE_ADMAC) += apple-admac.o obj-$(CONFIG_ARM_DMA350) += arm-dma350.o +obj-$(CONFIG_ATCDMAC300) += atcdmac300.o obj-$(CONFIG_AT_HDMAC) += at_hdmac.o obj-$(CONFIG_AT_XDMAC) += at_xdmac.o obj-$(CONFIG_AXI_DMAC) += dma-axi-dmac.o
drivers/dma/atcdmac300.c new file +1518 -0
1,518 lines not on this page · raw message
drivers/dma/atcdmac300.h new file +296 -0
296 lines not on this page · raw message
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v5 2/3] dmaengine: atcdmac300: Add driver for Andes ATCDMAC300 DMA controller
Thank you for your contribution! Sashiko AI review found 10 potential issue(s) to consider: - [High] Unmanaged `cyclic` flag leads to NULL pointer dereferences, infinite loops, and resume panics.…
Thank you for your contribution! Sashiko AI review found 10 potential issue(s) to consider:
- [High] Unmanaged cyclic flag leads to NULL pointer dereferences, infinite loops, and resume panics.
- [High] Interrupt handler masks hardware interrupt status with used_chan, leaving unmasked interrupts unacknowledged.
- [High] Premature execution of unissued DMA descriptors violates the DMA engine API.
- [High] Missing device_synchronize callback prevents safe client synchronization with the threaded IRQ handler.
- [High] Fetching the client callback outside the lock in atcdmac_advance_work creates a Use-After-Free race with channel termination.
- [High] Reusing descriptors from free_list does not clear previously set callbacks and parameters.
- [Medium] atcdmac_set_device_config strictly validates unused configuration fields, breaking unidirectional slave configurations.
- [Medium] Asymmetric registration and teardown order creates Use-After-Free vulnerabilities and Race Conditions.
- [Medium] Prepared but unsubmitted DMA descriptors are permanently leaked due to missing desc_free callback.
- [Medium] Truncation of size_t len to unsigned int trans_size could lead to incomplete DMA transfers on 64-bit platforms. --
commit 892196b95d4c6cbcb6477d01fb69f6b5e13d4612
Author: CL Wang <[email protected]>
dmaengine: atcdmac300: Add driver for Andes ATCDMAC300 DMA controller
This patch adds support for the Andes ATCDMAC300 DMA controller. It provides memory-to-memory and peripheral DMA controller support with scatter-gather, cyclic, and slave transfer capabilities.
Quoted 5 lines
drivers/dma/atcdmac300.c new file +0
-0@@ -0,0 +1,1518 @@
[ ... ]
Quoted 3 lines
drivers/dma/atcdmac300.c new file +3
-0+static struct atcdmac_desc *atcdmac_alloc_desc (struct dma_chan *chan, +gfp_t gfp_flags) +{
[ ... ]
drivers/dma/atcdmac300.c line 85
Quoted 5 lines
drivers/dma/atcdmac300.c new file +5
-0+ desc =dma_pool_zalloc (dmac->dma_desc_pool, gfp_flags, &phys); +if (desc) { +INIT_LIST_HEAD (&desc->tx_list); +dma_async_tx_descriptor_init (&desc->txd, chan); + desc->txd.flags =DMA_CTRL_ACK ;
[Severity: Medium]
Is there a missing assignment for the desc_free callback here?
When a client prepares a transaction, descriptors are removed from dmac_chan->free_list. If the client aborts and calls dmaengine_desc_free(), the dmaengine core attempts to invoke desc->txd.desc_free. Because atcdmac_alloc_desc() never assigns this callback, the core drops the descriptor.
Since atcdmac_free_chan_resources() only reclaims descriptors currently present in free_list, any orphaned, unsubmitted descriptors seem permanently leaked from dmac->dma_desc_pool. Can we add the appropriate callback to prevent pool exhaustion?
Quoted 6 lines
drivers/dma/atcdmac300.c new file +6
-0+ desc->txd.tx_submit = atcdmac_tx_submit; + desc->txd.phys = phys; + } + +return desc; +}
[ ... ]
Quoted 2 lines
drivers/dma/atcdmac300.c new file +2
-0+static struct atcdmac_desc *atcdmac_get_desc (struct atcdmac_chan *dmac_chan) +{
[ ... ]
drivers/dma/atcdmac300.c line 108
Quoted 9 lines
drivers/dma/atcdmac300.c new file +9
-0+spin_lock_irqsave (&dmac_chan->lock, flags); +list_for_each_entry_safe (desc, desc_next, + &dmac_chan->free_list, + desc_node) { +if (async_tx_test_ack (&desc->txd)) { +list_del_init (&desc->desc_node); + ret = desc; +break ; + }
[Severity: High]
Should the descriptor callback and parameter fields be reset before reusing it from the free_list?
When atcdmac_get_desc() retrieves a descriptor for a new transfer, it does not appear to zero out desc->txd.callback and desc->txd.callback_param. If a client previously used this descriptor with a callback, freed its context, and reuses it without setting a new callback, the DMA engine might inadvertently execute the stale callback.
Could this lead to use-after-free issues if the context is already freed?
Quoted 2 lines
drivers/dma/atcdmac300.c new file +2
-0+ } +spin_unlock_irqrestore (&dmac_chan->lock, flags);
[ ... ]
drivers/dma/atcdmac300.c line 295
Quoted 9 lines
drivers/dma/atcdmac300.c new file +9
-0+static void atcdmac_start_next_trans (struct atcdmac_chan *dmac_chan) +{ +struct atcdmac_desc *next_tx =NULL ; +struct atcdmac_desc *dma_desc; + +if (dmac_chan->cyclic) { +/* Get the next DMA descriptor from tx_list. */ + dma_desc =atcdmac_get_active_head (dmac_chan); + dma_desc->at = dma_desc->at->next;
[Severity: High]
Does this sequence safely handle channels that have transitioned from cyclic to non-cyclic transfers, or handle resume states properly?
The driver sets dmac_chan->cyclic to true in atcdmac_prep_dma_cyclic(), but this flag is never reset to false during atcdmac_terminate_all() or when preparing subsequent non-cyclic transfers like memcpy.
If a channel is used for a cyclic transfer, terminated, and then reused for a non-cyclic transfer, the stale cyclic state causes atcdmac_advance_work() to enter the cyclic path here. For memcpy descriptors, this leads to a null pointer dereference on dma_desc->at->next.
Additionally, during system resume, atcdmac_resume() unconditionally calls atcdmac_start_next_trans() on all channels. For a terminated cyclic channel, active_list is empty, causing atcdmac_get_active_head() to return an invalid pointer and crashing the kernel upon dereference.
drivers/dma/atcdmac300.c line 308
Quoted 13 lines
drivers/dma/atcdmac300.c new file +13
-0+if ((uintptr_t )dma_desc->at == (uintptr_t )&dma_desc->tx_list) + next_tx =list_entry (dma_desc->at, + struct atcdmac_desc, + tx_list); +else + next_tx =list_entry (dma_desc->at, + struct atcdmac_desc, + desc_node); + }else { +if (list_empty (&dmac_chan->active_list)) { +if (!list_empty (&dmac_chan->queue_list)) { +list_splice_init (&dmac_chan->queue_list, + &dmac_chan->active_list);
[Severity: High]
Is it safe to splice the entire queue_list into active_list without checking if the client has explicitly issued the pending descriptors?
The DMA engine API contract requires that descriptors submitted via tx_submit remain pending and are not started until the client explicitly calls dma_async_issue_pending().
However, atcdmac_advance_work() unconditionally splices unissued descriptors from queue_list into active_list when a prior transaction completes. Similarly, atcdmac_resume() pulls unissued descriptors from queue_list. If a client submits descriptors but intentionally delays issuing them (e.g. waiting for a peripheral), the driver will incorrectly execute them prematurely.
Quoted 2 lines
drivers/dma/atcdmac300.c new file +2
-0+ next_tx =atcdmac_get_active_head (dmac_chan); + }
[ ... ]
Quoted 2 lines
drivers/dma/atcdmac300.c new file +2
-0+static void atcdmac_advance_work (struct atcdmac_chan *dmac_chan) +{
[ ... ]
drivers/dma/atcdmac300.c line 371
Quoted 7 lines
drivers/dma/atcdmac300.c new file +7
-0+if (dmac_chan->cyclic) { +if (!stop) +atcdmac_start_next_trans (dmac_chan); + +spin_unlock_irqrestore (&dmac_chan->lock, flags); + res.result =DMA_TRANS_NOERROR ; +dmaengine_desc_get_callback_invoke (&dma_desc->txd, &res);
[Severity: High]
Does fetching the client callback outside the channel lock create a use-after-free race condition?
For cyclic transfers, dma_desc remains on active_list. The lock is dropped via spin_unlock_irqrestore() before accessing dma_desc->txd to invoke the callback.
While the lock is dropped, a concurrent dmaengine_terminate_all() can acquire the lock, splice the active_list away, and return dma_desc to the free_list. The client might then release the channel, freeing the descriptor back to the pool. The IRQ thread will then use the freed descriptor to invoke the callback. Should the callback information be extracted while the lock is still held?
Quoted 1 line
drivers/dma/atcdmac300.c new file +1
-0+ }else {
[ ... ]
drivers/dma/atcdmac300.c line 509
Quoted 13 lines
drivers/dma/atcdmac300.c new file +13
-0+static irqreturn_t atcdmac_interrupt (int irq,void *dev_id) +{ +struct atcdmac_dmac *dmac = dev_id; +struct atcdmac_chan *dmac_chan; +unsigned int status; +unsigned int int_ch; +int ret =IRQ_NONE ; +int i; + +regmap_read (dmac->regmap,REG_INT_STA , &status); + int_ch =READ_ONCE (dmac->used_chan) &DMA_INT_ALL (status); + +while (int_ch) {
[Severity: High]
Can this loop leave hardware interrupts unacknowledged and cause an interrupt storm?
The handler masks the hardware interrupt status with the software-tracked used_chan mask. It only clears the interrupts identified by int_ch. If the hardware asserts an interrupt for a channel not currently in used_chan (for instance, an ABT interrupt generated by atcdmac_terminate_all() on a previously idle channel, or a spurious interrupt), int_ch evaluates to 0.
Because the while loop is skipped, the handler will not clear REG_INT_STA and returns IRQ_NONE. Since the interrupt is level-triggered, the uncleared interrupt will immediately re-fire, causing an infinite loop until the kernel disables the IRQ line.
Quoted 4 lines
drivers/dma/atcdmac300.c new file +4
-0+spin_lock (&dmac->lock); + dmac->used_chan =READ_ONCE (dmac->used_chan) & ~int_ch; +spin_unlock (&dmac->lock); +regmap_write (dmac->regmap,REG_INT_STA ,DMA_INT_CLR (int_ch));
[ ... ]
Quoted 7 lines
drivers/dma/atcdmac300.c new file +7
-0+static struct dma_async_tx_descriptor * +atcdmac_prep_dma_memcpy (struct dma_chan *chan, +dma_addr_t dst, +dma_addr_t src, +size_t len, +unsigned long flags) +{
[ ... ]
drivers/dma/atcdmac300.c line 711
Quoted 8 lines
drivers/dma/atcdmac300.c new file +8
-0+ ctrl =SRC_BURST_SIZE (src_max_burst) | +SRC_ADDR_MODE_INCR | +DST_ADDR_MODE_INCR | +DST_WIDTH (dst_width) | +SRC_WIDTH (src_width); + + desc =atcdmac_build_desc (dmac_chan, src, dst, ctrl, + len >> src_width,1 );
[Severity: Medium]
Could the truncation of size_t len lead to incomplete DMA transfers on 64-bit platforms?
Here, the 64-bit size_t len is shifted and passed as an unsigned int into atcdmac_build_desc(). If a user requests a transfer length such that len >> src_width exceeds 32 bits, the value will be silently truncated. The DMA hardware would perform a shorter transfer but report success, leading to silent data corruption. Is there a way to safely bound or reject overly large sizes?
Quoted 2 lines
drivers/dma/atcdmac300.c new file +2
-0+if (!desc) + goto err_desc_get;
[ ... ]
Quoted 5 lines
drivers/dma/atcdmac300.c new file +5
-0+static int atcdmac_set_device_config (struct dma_chan *chan, +struct dma_slave_config *sconfig) +{ +struct atcdmac_chan *dmac_chan =atcdmac_chan_to_dmac_chan (chan); +
drivers/dma/atcdmac300.c line 934
Quoted 10 lines
drivers/dma/atcdmac300.c new file +10
-0+/* Check if this chan is configured for device transfers */ +if (!dmac_chan->dev_chan) +return -EINVAL ; + +/* Must be powers of two according to ATCDMAC300 spec */ +if (!is_power_of_2 (sconfig->src_maxburst) || + !is_power_of_2 (sconfig->dst_maxburst) || + !is_power_of_2 (sconfig->src_addr_width) || + !is_power_of_2 (sconfig->dst_addr_width)) +return -EINVAL ;
[Severity: Medium]
Does this check incorrectly reject valid, standard unidirectional configurations?
Standard DMA engine consumers populate only the dma_slave_config fields corresponding to their active transfer direction, leaving fields for the unused direction as 0.
Because is_power_of_2(0) returns false, this strict global validation rejects perfectly valid setups with -EINVAL, forcing clients to provide dummy parameters for unused directions. Could the validation be limited to the active transfer direction?
Quoted 2 lines
drivers/dma/atcdmac300.c new file +2
-0+ +memcpy (&dmac_chan->dma_sconfig, sconfig,sizeof (*sconfig));
[ ... ]
Quoted 4 lines
drivers/dma/atcdmac300.c new file +4
-0+static void atcdmac_init_dma_device (struct platform_device *pdev, +struct atcdmac_dmac *dmac) +{ +struct dma_device *device = &dmac->dma_device;
drivers/dma/atcdmac300.c line 1219
Quoted 10 lines
drivers/dma/atcdmac300.c new file +10
-0+ + device->device_alloc_chan_resources = atcdmac_alloc_chan_resources; + device->device_free_chan_resources = atcdmac_free_chan_resources; + device->device_tx_status = atcdmac_get_tx_status; + device->device_issue_pending = atcdmac_issue_pending; + device->device_prep_dma_memcpy = atcdmac_prep_dma_memcpy; + device->device_prep_slave_sg = atcdmac_prep_device_sg; + device->device_config = atcdmac_set_device_config; + device->device_terminate_all = atcdmac_terminate_all; + device->device_prep_dma_cyclic = atcdmac_prep_dma_cyclic;
[Severity: High]
Is the device_synchronize callback missing from this list?
The driver processes completions and invokes client callbacks in a threaded IRQ handler (atcdmac_advance_work). Clients rely on dmaengine_terminate_sync() to ensure all transfers are aborted and no callbacks are executing before freeing resources.
Without a device_synchronize callback, dmaengine_terminate_sync() fails to wait for the threaded IRQ. If a client unloads immediately after calling it, the IRQ thread may still be executing the client's callback, triggering a use-after-free or executing unloaded module code.
Quoted 2 lines
drivers/dma/atcdmac300.c new file +2
-0+ + device->dev = &pdev->dev;
[ ... ]
Quoted 2 lines
drivers/dma/atcdmac300.c new file +2
-0+static int atcdmac_probe (struct platform_device *pdev) +{
[ ... ]
drivers/dma/atcdmac300.c line 1411
Quoted 7 lines
drivers/dma/atcdmac300.c new file +7
-0+atcdmac_init_dma_device (pdev, dmac); + + ret =dma_async_device_register (&dmac->dma_device); +if (ret) +return ret; + + ret =atcdmac_init_irq (pdev, dmac);
[Severity: Medium]
Does registering the device before fully initializing it expose the driver to use-after-free or race conditions?
Here, dma_async_device_register() is called before atcdmac_init_irq() and atcdmac_init_iocp(). Once registered, the device is globally visible and clients can acquire channels and submit transfers before the IRQ handler or cache consistency parameters are fully set up.
If the subsequent initialization steps fail, dmac is freed while a client may be holding a channel reference. Symmetrically, in atcdmac_remove(), the driver resets the hardware before calling dma_async_device_unregister(), meaning active clients may submit new transfers that the now-reset hardware will attempt to execute. Should registration happen at the very end of probe?
Quoted 4 lines
drivers/dma/atcdmac300.c new file +4
-0+if (ret) + goto err_dma_async_register; + + ret =atcdmac_init_iocp (pdev, dmac);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH v5 3/3 MAINTAINERS: Add entry for Andes ATCDMAC300
In reply to CL WangAdd a MAINTAINERS entry for the Andes ATCDMAC300 DMA engine driver and its associated Device Tree bindings.
---
Changes for v5:
- No changes from v4
Changes for v4:
- No changes from v3
--- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
@@ -1868,6 +1868,12 @@ S: Supported F: drivers/clk/analogbits/* F: include/linux/clk/analogbits* +ANDES ATCDMAC300 DMA DRIVER +M: CL Wang <[email protected]> +S: Supported +F: Documentation/devicetree/bindings/dma/andestech,ae350-dma.yaml +F: drivers/dma/atcdmac300* + ANDES ATCSPI200 SPI DRIVER M: CL Wang <[email protected]> S: Supported
Signature · 1 line
2.34.1