apache / apache/nuttx

[BUG] uart_recvchars_dma may cause address missalignment issues.

Open
#16,784 2 comments 0 reactions 0 assignees View on GitHub
Arch: all Area: Drivers OS: BSD Type: Bug
Dominant language
C
Stars
4k
Forks
1.7k
Avg merge
1d 17h
Merged PRs (30d)
237

Description

### Description / Steps to reproduce the issue

```
void uart_recvchars_dma(FAR uart_dev_t *dev)
{

···
if (rxbuf->tail <= rxbuf->head)
{
xfer->buffer = &rxbuf->buffer[rxbuf->head];
xfer->nbuffer = rxbuf->buffer;

if (rxbuf->tail > 0)
{
xfer->length = rxbuf->size - rxbuf->head;
xfer->nlength = rxbuf->tail - 1;
}
else
{
xfer->length = rxbuf->size - rxbuf->head - 1;
xfer->nlength = 0;
}
}
else
{
xfer->buffer = &rxbuf->buffer[rxbuf->head];
xfer->length = rxbuf->tail - rxbuf->head - 1;
xfer->nbuffer = NULL;
xfer->nlength = 0;
}
uart_dmareceive(dev);

}
```
The head is the write pointer and is initially 0. For example, after receiving three bytes, the head becomes 3, which may cause the underlying DMA setup to fail.

### On which OS does this issue occur?

[OS: BSD]

### What is the version of your OS?

all os

### NuttX Version

last

### Issue Architecture

[Arch: all]

### Issue Area

[Area: Drivers]

### Host information

_No response_

### Verification

- [x] I have verified before submitting the report.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.