From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dariusz.stojaczyk@intel.com>
Received: from mga12.intel.com (mga12.intel.com [192.55.52.136])
 by dpdk.org (Postfix) with ESMTP id 69AD64CA2
 for <dev@dpdk.org>; Mon,  5 Nov 2018 08:08:13 +0100 (CET)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga001.fm.intel.com ([10.253.24.23])
 by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 04 Nov 2018 23:08:12 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.54,467,1534834800"; d="scan'208";a="105308426"
Received: from violet.igk.intel.com ([10.102.54.137])
 by fmsmga001.fm.intel.com with ESMTP; 04 Nov 2018 23:08:08 -0800
From: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, Darek Stojaczyk <dariusz.stojaczyk@intel.com>,
 qi.z.zhang@intel.com
Date: Mon,  5 Nov 2018 08:04:45 +0100
Message-Id: <20181105070447.67700-1-dariusz.stojaczyk@intel.com>
X-Mailer: git-send-email 2.17.1
Subject: [dpdk-dev] [PATCH 1/3] bus/pci: update device devargs on each rescan
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 05 Nov 2018 07:08:13 -0000

Bus rescan is done e.g. during the device hotplug,
where devargs are re-allocated. By not updating the
rte_device->devargs pointer we potentially make it
a dangling one, as previous devargs could have been
(or will be soon) freed.

Fixes: 55e411b301c3 ("bus/pci: fix resource mapping override")
Cc: qi.z.zhang@intel.com

Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
---
 drivers/bus/pci/linux/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index f87533c5c..f3172960e 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -349,10 +349,10 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
 			if (ret < 0) {
 				rte_pci_insert_device(dev2, dev);
 			} else { /* already registered */
+				pci_name_set(dev2);
 				if (!rte_dev_is_probed(&dev2->device)) {
 					dev2->kdrv = dev->kdrv;
 					dev2->max_vfs = dev->max_vfs;
-					pci_name_set(dev2);
 					memmove(dev2->mem_resource,
 						dev->mem_resource,
 						sizeof(dev->mem_resource));
-- 
2.17.1