This is an automated email from the ASF dual-hosted git repository. michallenc pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 3f512dd65227978793fc4020bf575d5fe3c005a5 Author: Bowen Wang <[email protected]> AuthorDate: Thu Aug 28 14:34:03 2025 +0800 drivers/rptun: check remoteproc_mmap() when assigning vring addresses rptun_update_vring_da() ignored the result of remoteproc_mmap(). When the mapping failed, vring_da was left undefined but still written to the vring and the shared memory pointer was advanced past it. Log an error and skip the vring instead. Signed-off-by: Bowen Wang <[email protected]> --- drivers/rptun/rptun.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/rptun/rptun.c b/drivers/rptun/rptun.c index e8581f25927..e67383cdb0e 100644 --- a/drivers/rptun/rptun.c +++ b/drivers/rptun/rptun.c @@ -409,16 +409,19 @@ static void rptun_update_vring_da(FAR struct remoteproc *rproc, vring_sz = ALIGN_UP(vring_size(vring->num, vring->align), vring->align); vring_pa = metal_io_virt_to_phys(metal_io_get_region(), *shmbase); - remoteproc_mmap(rproc, &vring_pa, &vring_da, vring_sz, 0, NULL); - rptuninfo("vr[%u] shm=%p len=%zu da=0x%lx pa=0x%lx sz=%" PRIu32 "\n", - i, *shmbase, *shmlen, vring_da, vring_pa, vring_sz); - - if (vring->da == 0u || vring->da == FW_RSC_U32_ADDR_ANY) + if (!remoteproc_mmap(rproc, &vring_pa, &vring_da, vring_sz, 0, NULL)) + { + rptunerr("vr[%u] da=0x%lx pa=0x%lx sz=%" PRIu32 "\n", + i, vring_da, vring_pa, vring_sz); + } + else if (vring->da == 0u || vring->da == FW_RSC_U32_ADDR_ANY) { + rptuninfo("vr[%u] shm=%p len=%zu da=0x%lx pa=0x%lx sz=%"PRIu32"\n", + i, *shmbase, *shmlen, vring_da, vring_pa, vring_sz); vring->da = vring_da; - *shmbase += vring_sz; - *shmlen -= vring_sz; + *shmbase += vring_sz; + *shmlen -= vring_sz; } } }
