xiaoxiang781216 commented on code in PR #16356: URL: https://github.com/apache/nuttx/pull/16356#discussion_r2083870748
########## drivers/misc/optee.c: ########## @@ -1155,38 +1223,31 @@ int optee_shm_alloc(FAR struct optee_priv_data *priv, FAR void *addr, * ****************************************************************************/ -void optee_shm_free(FAR struct optee_priv_data *priv, - FAR struct optee_shm_entry *shme) +void optee_shm_free(FAR struct optee_shm_entry *shme) { - irqstate_t irqstate; - if (!shme) { return; } - if (shme->shm.flags & TEE_SHM_SEC_REGISTER) + if (shme->flags & TEE_SHM_REGISTER) { - optee_shm_sec_unregister(priv, shme); + optee_shm_unregister(shme->priv, shme); } - if (shme->shm.flags & TEE_SHM_REGISTER) + if (shme->flags & TEE_SHM_ALLOC) { - irqstate = spin_lock_irqsave(&priv->lock); - - if (list_in_list(&shme->node)) - { - list_delete(&shme->node); - } - - spin_unlock_irqrestore(&priv->lock, irqstate); + kmm_free((FAR void *)(uintptr_t)shme->addr); } - if (shme->shm.flags & TEE_SHM_ALLOC) + if (!(shme->flags & (TEE_SHM_ALLOC | TEE_SHM_REGISTER))) { - kmm_free((FAR void *)(uintptr_t)shme->shm.addr); + /* allocated by optee_ioctl_shm_alloc(), need to unmap */ + + munmap((FAR void *)(uintptr_t)shme->addr, shme->length); Review Comment: if kernel don't use addr in this case, why not skip map in optee_ioctl_shm_alloc -- 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