mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-16 01:05:15 +08:00
[drivers][virtio] Fix RX buffer leak on pbuf allocation failure
This commit is contained in:
1 parent
e2e507c499
commit
67861fa4fd
1 file changed
+13
@@ -124,6 +124,19 @@ static struct pbuf *virtio_net_rx(rt_device_t dev)
|
||||
|
||||
if (!p)
|
||||
{
|
||||
level = rt_spin_lock_irqsave(&vnet->rx_lock);
|
||||
|
||||
if (!rt_virtqueue_poll(vq, packet - vnet->rx_packet))
|
||||
{
|
||||
rt_list_remove(&vq->user_list);
|
||||
}
|
||||
|
||||
rt_virtqueue_add_inbuf(vq, packet, sizeof(*packet));
|
||||
|
||||
rt_virtqueue_kick(vq);
|
||||
|
||||
rt_spin_unlock_irqrestore(&vnet->rx_lock, level);
|
||||
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user