From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 9FFDB1B122 for ; Wed, 21 Nov 2018 20:06:39 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Nov 2018 11:06:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,262,1539673200"; d="scan'208";a="106599785" Received: from violet.igk.intel.com ([10.102.54.137]) by fmsmga002.fm.intel.com with ESMTP; 21 Nov 2018 11:06:37 -0800 From: Darek Stojaczyk To: dev@dpdk.org Cc: Darek Stojaczyk , qi.z.zhang@intel.com Date: Wed, 21 Nov 2018 20:05:07 +0100 Message-Id: <20181121190507.61845-1-dariusz.stojaczyk@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] dev: don't try to rollback a device attach that failed X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Nov 2018 19:06:40 -0000 If a device fails to attach before it's plugged, the subsequent rollback will still try to detach it, causing a segfault. Unplugging a device that wasn't plugged isn't really supported, so this patch adds an extra error check to prevent that from happening. While here, fix this also for normal (non-rollback) detach, which could also theoretically segfault on non-plugged device. Fixes: 244d5130719c ("eal: enable hotplug on multi-process") Cc: qi.z.zhang@intel.com Signed-off-by: Darek Stojaczyk --- lib/librte_eal/common/hotplug_mp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/librte_eal/common/hotplug_mp.c b/lib/librte_eal/common/hotplug_mp.c index 7c9fcc46c..d9e6790da 100644 --- a/lib/librte_eal/common/hotplug_mp.c +++ b/lib/librte_eal/common/hotplug_mp.c @@ -264,6 +264,19 @@ static void __handle_primary_request(void *param) goto quit; } + if (!rte_dev_is_probed(dev)) { + if (req->t == EAL_DEV_REQ_TYPE_ATTACH_ROLLBACK) { + /** + * Don't fail the rollback just because there's + * nothing to do. + */ + ret = 0; + } else + ret = -ENODEV; + + goto quit; + } + ret = local_dev_remove(dev); quit: free(da->args); -- 2.17.1