[PATCH] hw/net/rocker: fix assertion error while hotunplugging

Zheng Huang posted 1 patch 3 days, 22 hours ago
hw/net/rocker/rocker.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] hw/net/rocker: fix assertion error while hotunplugging
Posted by Zheng Huang 3 days, 22 hours ago
Hi,

This patch fixes assertion error `vector < dev->msix_entries_nr` while 
hot-unplugging rocker device. In `rocker_msix_uninit()`, `msix_uninit()`
will clear the field `msix_entries_nr` and free the `msix_entry_used`,
which are used later in `rocker_msix_vectors_unuse()` for msix clearing.
Swapping this two calls will fix the issue.

Relative codes:

>// Clearing
>@@ void msix_uninit(PCIDevice *dev, MemoryRegion *table_bar, MemoryRegion *pba_bar)
>dev->msix_entries_nr = 0;
>// ...
>g_free(dev->msix_entry_used);
>
>// Using
>@@ void msix_vector_unuse(PCIDevice *dev, unsigned vector)
>{
>    assert(vector < dev->msix_entries_nr);
>    if (!dev->msix_entry_used[vector]) {
>    // ...
>    msix_clr_pending(dev, vector);
>}


Signed-off-by: Zheng Huang <hz1624917200@gmail.com>

---
 hw/net/rocker/rocker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
index aa5d87fbc5..8752ea4aec 100644
--- a/hw/net/rocker/rocker.c
+++ b/hw/net/rocker/rocker.c
@@ -1241,8 +1241,8 @@ static void rocker_msix_uninit(Rocker *r)
 {
     PCIDevice *dev = PCI_DEVICE(r);
 
-    msix_uninit(dev, &r->msix_bar, &r->msix_bar);
     rocker_msix_vectors_unuse(r, ROCKER_MSIX_VEC_COUNT(r->fp_ports));
+    msix_uninit(dev, &r->msix_bar, &r->msix_bar);
 }
 
 static World *rocker_world_type_by_name(Rocker *r, const char *name)
-- 
2.34.1