diff --git a/components/drivers/src/pipe.c b/components/drivers/src/pipe.c index ae87b6f5f2..393370fc9a 100644 --- a/components/drivers/src/pipe.c +++ b/components/drivers/src/pipe.c @@ -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));