Skip to content

Commit

Permalink
drivers/optee: Return error if optee_recv return prematurely
Browse files Browse the repository at this point in the history
Signed-off-by: Xiang Xiao <[email protected]>
  • Loading branch information
xiaoxiang781216 authored and hujun260 committed Oct 12, 2024
1 parent a2b129f commit e8ad00a
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions drivers/misc/optee.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,24 +291,21 @@ static int optee_from_msg_param(FAR struct tee_ioctl_param *params,
return 0;
}

static ssize_t optee_recv(FAR struct socket *psock, FAR void *msg,
size_t size)
static int optee_recv(FAR struct socket *psock, FAR void *msg, size_t size)
{
size_t remain = size;

while (remain)
while (size > 0)
{
ssize_t n = psock_recv(psock, msg, remain, 0);
ssize_t n = psock_recv(psock, msg, size, 0);
if (n <= 0)
{
return remain == size ? n : size - remain;
return n < 0 ? n : -EIO;
}

remain -= n;
size -= n;
msg = (FAR char *)msg + n;
}

return size;
return 0;
}

static int optee_send_recv(FAR struct socket *psocket,
Expand Down

0 comments on commit e8ad00a

Please sign in to comment.