This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit ead1fa989644ae6a0a9400b33724a93358d062c0
Author: hujun5 <[email protected]>
AuthorDate: Mon Jan 26 19:11:12 2026 +0800

    drivers/tee/optee: Simplify memory map entry handling in shm_mmap
    
    Eliminate unnecessary mm_map_find() call and directly use the map_entry
    parameter passed to optee_shm_mmap(). This simplifies the code logic and
    reduces memory lookups by using the already-resolved mm_map_entry_s
    structure provided by the mmap operation.
    
    Signed-off-by: hujun5 <[email protected]>
---
 drivers/tee/optee.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/tee/optee.c b/drivers/tee/optee.c
index bece11acd52..1321fd31efb 100644
--- a/drivers/tee/optee.c
+++ b/drivers/tee/optee.c
@@ -496,7 +496,6 @@ static int optee_shm_mmap(FAR struct file *filep,
 {
   FAR struct optee_shm *shm = filep->f_priv;
   FAR struct optee_priv_data *priv = shm->priv;
-  FAR struct mm_map_entry_s *entry;
   int32_t ret = OK;
 
   if ((map->flags & MAP_PRIVATE) && (map->flags & MAP_SHARED))
@@ -529,19 +528,16 @@ static int optee_shm_mmap(FAR struct file *filep,
       shm->paddr = optee_va_to_pa(map->vaddr);
       shm->flags |= TEE_SHM_REGISTER;
 
-      entry = mm_map_find(get_current_mm(), map->vaddr, map->length);
-      DEBUGASSERT(entry != NULL);
-
-      shm->munmap = entry->munmap;
-      entry->munmap = optee_shm_munmap;
-      shm->p = entry->priv.p;
-      entry->priv.p = shm;
+      shm->munmap = map->munmap;
+      map->munmap = optee_shm_munmap;
+      shm->p = map->priv.p;
+      map->priv.p = shm;
 
       ret = optee_shm_register(priv, shm);
       if (ret < 0)
         {
-          shm->munmap(nxsched_self()->group, entry,
-                      entry->vaddr, entry->length);
+          shm->munmap(nxsched_self()->group, map,
+                      map->vaddr, map->length);
           optee_shm_free(shm);
         }
     }

Reply via email to