tkaratapanis commented on code in PR #16734: URL: https://github.com/apache/nuttx/pull/16734#discussion_r2229436507
########## drivers/misc/optee.c: ########## @@ -1088,6 +1034,130 @@ optee_ioctl_shm_register(FAR struct optee_priv_data *priv, return ret; } +#ifdef CONFIG_DEV_OPTEE_SUPPLICANT +static +int optee_ioctl_supplicant_recv(FAR struct optee_priv_data *priv, + FAR struct tee_ioctl_buf_data *data) +{ + int ret; + FAR struct tee_iocl_supp_recv_arg *arg; + + if (!optee_is_valid_range(data, sizeof(*data))) + { + return -EFAULT; + } + + if (!optee_is_valid_range((void *)data->buf_ptr, data->buf_len)) + { + return -EFAULT; + } + + if (data->buf_len > TEE_MAX_ARG_SIZE || + data->buf_len < sizeof(struct tee_iocl_supp_recv_arg)) + { + return -EINVAL; + } + + arg = (FAR struct tee_iocl_supp_recv_arg *)(uintptr_t)data->buf_ptr; + + if (sizeof(*arg) + TEE_IOCTL_PARAM_SIZE(arg->num_params) != + data->buf_len) + { + return -EINVAL; + } + + if (arg->num_params > OPTEE_MAX_PARAM_NUM) + { + return -EINVAL; + } + + ret = optee_supplicant_recv(&arg->func, &arg->num_params, arg->params); + + if (ret) + { + goto out; Review Comment: I changed it now to `if (ret < 0)` but I still think` if (ret != 0)` is more accurate. -- 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