From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: [PATCH v2] bus/vdev: fix scope of device list lock Date: Mon, 21 May 2018 18:45:44 +0200 Message-ID: <20180521164544.26421-1-thomas@monjalon.net> References: <20180521161156.25724-1-thomas@monjalon.net> Cc: matan@mellanox.com, ferruh.yigit@intel.com To: dev@dpdk.org Return-path: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 4355B1B20E for ; Mon, 21 May 2018 18:45:59 +0200 (CEST) In-Reply-To: <20180521161156.25724-1-thomas@monjalon.net> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The lock vdev_device_list_lock was taken before calling "remove" function for the device. So it prevents to remove sub-devices (as in failsafe) inside its own "remove" function, because of a deadlock. The lock is now only protecting the device list inside the bus driver. Fixes: 35f462839b69 ("bus/vdev: add lock on device list") Signed-off-by: Thomas Monjalon --- v2: reduce scope more by moving unlock --- drivers/bus/vdev/vdev.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index 099b9ff85..470cff46c 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -293,25 +293,24 @@ rte_vdev_uninit(const char *name) if (name == NULL) return -EINVAL; - rte_spinlock_lock(&vdev_device_list_lock); - dev = find_vdev(name); if (!dev) { ret = -ENOENT; - goto unlock; + return ret; } ret = vdev_remove_driver(dev); if (ret) - goto unlock; + return ret; + rte_spinlock_lock(&vdev_device_list_lock); TAILQ_REMOVE(&vdev_device_list, dev, next); + rte_spinlock_unlock(&vdev_device_list_lock); + devargs = dev->device.devargs; rte_devargs_remove(devargs->bus->name, devargs->name); free(dev); -unlock: - rte_spinlock_unlock(&vdev_device_list_lock); return ret; } -- 2.16.2