mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-07-07 10:15:45 +00:00
net_util: Check descriptor size
There is no point in queueing an empty descriptor in the list of iovecs. Let's simply ignore such case and avoid some unnecessary processing. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
1cd186c83c
commit
63304d0be7
@ -43,7 +43,7 @@ impl TxVirtio {
|
|||||||
|
|
||||||
let mut iovecs = Vec::new();
|
let mut iovecs = Vec::new();
|
||||||
while let Some(desc) = next_desc {
|
while let Some(desc) = next_desc {
|
||||||
if !desc.is_write_only() {
|
if !desc.is_write_only() && desc.len > 0 {
|
||||||
let buf = mem
|
let buf = mem
|
||||||
.get_slice(desc.addr, desc.len as usize)
|
.get_slice(desc.addr, desc.len as usize)
|
||||||
.map_err(NetQueuePairError::GuestMemory)?
|
.map_err(NetQueuePairError::GuestMemory)?
|
||||||
@ -118,7 +118,7 @@ impl RxVirtio {
|
|||||||
|
|
||||||
let mut iovecs = Vec::new();
|
let mut iovecs = Vec::new();
|
||||||
while let Some(desc) = next_desc {
|
while let Some(desc) = next_desc {
|
||||||
if desc.is_write_only() {
|
if desc.is_write_only() && desc.len > 0 {
|
||||||
let buf = mem
|
let buf = mem
|
||||||
.get_slice(desc.addr, desc.len as usize)
|
.get_slice(desc.addr, desc.len as usize)
|
||||||
.map_err(NetQueuePairError::GuestMemory)?
|
.map_err(NetQueuePairError::GuestMemory)?
|
||||||
|
Loading…
Reference in New Issue
Block a user