diff options
author | Li Qiang <liq3ea@gmail.com> | 2017-02-09 18:19:19 -0800 |
---|---|---|
committer | Jason Wang <jasowang@redhat.com> | 2017-02-15 11:18:57 +0800 |
commit | 4154c7e03fa55b4cf52509a83d50d6c09d743b77 (patch) | |
tree | a3dfadd929794d9ea5bd6bd80cfa76ee6a8a4602 /hw/net/e1000e_core.c | |
parent | 81f17e0d435c3db3a3e67e0d32ebf9c98973211f (diff) |
net: e1000e: fix an infinite loop issue
This issue is like the issue in e1000 network card addressed in
this commit:
e1000: eliminate infinite loops on out-of-bounds transfer start.
Signed-off-by: Li Qiang <liqiang6-s@360.cn>
Reviewed-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'hw/net/e1000e_core.c')
-rw-r--r-- | hw/net/e1000e_core.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index c99e2fbd62..28c5be1506 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -806,7 +806,8 @@ typedef struct E1000E_RingInfo_st { static inline bool e1000e_ring_empty(E1000ECore *core, const E1000E_RingInfo *r) { - return core->mac[r->dh] == core->mac[r->dt]; + return core->mac[r->dh] == core->mac[r->dt] || + core->mac[r->dt] >= core->mac[r->dlen] / E1000_RING_DESC_LEN; } static inline uint64_t @@ -1522,6 +1523,10 @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt, desc_size = core->rx_desc_buf_size; } + if (e1000e_ring_empty(core, rxi)) { + return; + } + base = e1000e_ring_head_descr(core, rxi); pci_dma_read(d, base, &desc, core->rx_desc_len); |