tkaratapanis commented on code in PR #16734:
URL: https://github.com/apache/nuttx/pull/16734#discussion_r2219191728


##########
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;
+    }
+
+  for (int n = 0; n < arg->num_params; n++)
+    {
+      FAR struct tee_ioctl_param *p = arg->params + n;
+
+      switch (p->attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK)
+        {
+          case TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT:
+          case TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INOUT:
+            break;
+          case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT:
+          case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT:
+          case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT:
+            if (!p->b)
+              {
+                p->a = 0;
+                p->c = (uint64_t)-1; /* invalid shm id */
+                break;
+              }
+          break;
+        default:
+          break;
+        }
+    }
+
+out:
+  return ret;
+}
+
+static
+int optee_ioctl_supplicant_send(FAR struct optee_priv_data *priv,

Review Comment:
   done



-- 
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

Reply via email to