diff --git a/components/drivers/ipc/ringblk_buf.c b/components/drivers/ipc/ringblk_buf.c index ab160270c4..6196747838 100644 --- a/components/drivers/ipc/ringblk_buf.c +++ b/components/drivers/ipc/ringblk_buf.c @@ -215,6 +215,7 @@ rt_rbb_blk_t rt_rbb_blk_alloc(rt_rbb_t rbb, rt_size_t blk_size) else { /* no space */ + rt_slist_insert(&rbb->free_list, &new_rbb->list); new_rbb = RT_NULL; } } @@ -239,6 +240,7 @@ rt_rbb_blk_t rt_rbb_blk_alloc(rt_rbb_t rbb, rt_size_t blk_size) else { /* no space */ + rt_slist_insert(&rbb->free_list, &new_rbb->list); new_rbb = RT_NULL; } } @@ -246,16 +248,21 @@ rt_rbb_blk_t rt_rbb_blk_alloc(rt_rbb_t rbb, rt_size_t blk_size) else { /* the list is empty */ - list_append(rbb, &new_rbb->list); - new_rbb->status = RT_RBB_BLK_INITED; - new_rbb->buf = rbb->buf; - new_rbb->size = blk_size; + if(blk_size <= rbb->buf_size) + { + list_append(rbb, &new_rbb->list); + new_rbb->status = RT_RBB_BLK_INITED; + new_rbb->buf = rbb->buf; + new_rbb->size = blk_size; + } + else + { + /* no space */ + rt_slist_insert(&rbb->free_list, &new_rbb->list); + new_rbb = RT_NULL; + } } } - else - { - new_rbb = RT_NULL; - } rt_spin_unlock_irqrestore(&(rbb->spinlock), level);