Skip to contentSkip to conversation

hw/net/rocker: fix assertion error while hotunplugging

PATCH New Zheng Huang 1 participant 1 message Mar 28, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/net/rocker: fix assertion error while hotunplugging

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:

Quoted 6 lines

// Clearing
@@ void msix_uninit(PCIDevice *dev, MemoryRegion *table_bar, MemoryRegion *pba_bar) dev->msix_entries_nr = 0;
// ...
g_free(dev->msix_entry_used);

Quoted 8 lines

// 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);
}
---
 hw/net/rocker/rocker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/rocker/rocker.c +1 -1
index aa5d87fbc5..8752ea4aec 100644
@@ -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)
Signature · 1 line
2.34.1