tkaratapanis commented on code in PR #16734: URL: https://github.com/apache/nuttx/pull/16734#discussion_r2219190713
########## drivers/misc/optee.c: ########## @@ -491,6 +488,45 @@ static int optee_shm_close(FAR struct file *filep) return 0; } +/**************************************************************************** + * Name: optee_shm_mmap + * + * Description: + * shm mmap operation + * + * Parameters: + * filep - the file instance + * map - Filled by the userspace, with the mapping parameters. + * + * Returned Values: + * OK on success; A negated errno value is returned on any failure. + * + ****************************************************************************/ + +static int optee_shm_mmap(FAR struct file *filep, + FAR struct mm_map_entry_s *map) +{ + struct optee_shm *shm = filep->f_priv; + int32_t ret = OK; + + if ((map->flags & MAP_PRIVATE) && (map->flags & MAP_SHARED)) + { + return -EINVAL; + } + + ret = map_anonymous(map, MAP_USER); + + if (ret == OK) + { + DEBUGASSERT(map->vaddr != NULL); + memset(map->vaddr, 0, map->length); Review Comment: In the end, i skipped this` memset()`, since `map_anonymous()` is already guaranteed to zero initialize the pages, (earlier I used `memset()` as defensive programming but I don't think it is needed here) ########## drivers/misc/optee.c: ########## @@ -1218,15 +1239,18 @@ int optee_shm_alloc(FAR struct optee_priv_data *priv, FAR void *addr, ptr = addr; } - if (ptr == NULL) + if (!(flags & TEE_SHM_USER_MAP)) { - goto err; + if (ptr == NULL) Review Comment: merged -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org