[components/drivers] update pipe.c

Fixed stackover flow bug when create pipe->fifo
This commit is contained in:
David Lin 2020-04-12 11:58:33 +08:00 committed by GitHub
parent 5b300113f7
commit ff09587d23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -330,6 +330,11 @@ rt_err_t rt_pipe_open (rt_device_t device, rt_uint16_t oflag)
if (pipe->fifo == RT_NULL)
{
pipe->fifo = rt_ringbuffer_create(pipe->bufsz);
if (pipe->fifo == RT_NULL)
{
rt_mutex_release(&(pipe->lock));
return -RT_ENOMEM;
}
}
rt_mutex_release(&(pipe->lock));