From 89ca7df0deb48cf8a9d4e6a68f11a5ad6d6d6787 Mon Sep 17 00:00:00 2001 From: Steven Luong Date: Thu, 8 Apr 2021 09:31:27 -0700 Subject: avf: crash on avf interface delete When deleting an avf interface which is not the very first interface that was created (dev_instance == 0), VPP crashes. The reason is every avf interface delete always removes the very first device instance due to ad->dev_instance was wiped out prior to the statement pool_put_index (am->devices, ad->dev_instance) Type: fix Signed-off-by: Steven Luong Change-Id: I69bd1588aab9a176f8eef46be7aa5063f5d29482 --- src/plugins/avf/device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/avf/device.c b/src/plugins/avf/device.c index c58b5124e68..14ad47c9854 100644 --- a/src/plugins/avf/device.c +++ b/src/plugins/avf/device.c @@ -1469,6 +1469,7 @@ avf_delete_if (vlib_main_t * vm, avf_device_t * ad, int with_barrier) vnet_main_t *vnm = vnet_get_main (); avf_main_t *am = &avf_main; int i; + u32 dev_instance; ad->flags &= ~AVF_DEVICE_F_ADMIN_UP; @@ -1523,8 +1524,9 @@ avf_delete_if (vlib_main_t * vm, avf_device_t * ad, int with_barrier) vec_free (ad->name); clib_error_free (ad->error); + dev_instance = ad->dev_instance; clib_memset (ad, 0, sizeof (*ad)); - pool_put_index (am->devices, ad->dev_instance); + pool_put_index (am->devices, dev_instance); clib_mem_free (ad); } -- cgit 1.2.3-korg