From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pb0-f53.google.com (mail-pb0-f53.google.com [209.85.160.53]) by dpdk.org (Postfix) with ESMTP id D72F42E89 for ; Wed, 4 Sep 2013 09:34:17 +0200 (CEST) Received: by mail-pb0-f53.google.com with SMTP id up15so7115550pbc.12 for ; Wed, 04 Sep 2013 00:34:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1BcYcXADW7sb4RR2xkCuTDZ0iHEcyvx6vJfWQGbXqWA=; b=iUhGKQr+Jt5iYIn7u66HzuFpVe3cxi1jD9EeksdhbWVV8Ep646LkDtu6W9t94l2eJX 6wFW6igxjHaF4X4YF8qvWJYc15LlGmljCyKx5YJwf6V+7711Pm92Bb9lSgc7yFrnBXhb IOHv3Umatsu7p+sOXNuc3OKlV8eTe+l1dM/1zv7eapi4ZplLXflTm7drtfOqMdVdMbmk IErpykMiv11ZEXdVy1MdIEIdgeaEkcaxOYAEbYdaj9H4PdjnIKRoJckvY/UqKoowpSST CQv8Abwu/mQTSjFtVVO72tv8sQ/uzf+o3IRtf39I3DyHGiew19pigFuzubrHL6XGzrHm b8Pg== X-Gm-Message-State: ALoCoQn/mN8BeQv1MBuDuuDKdyUhbzAI2hv0Efg6yENy9jwREDtq28Y7NMqrWtyVGc5IgBs8AELP X-Received: by 10.66.161.138 with SMTP id xs10mr1812509pab.56.1378280091677; Wed, 04 Sep 2013 00:34:51 -0700 (PDT) Received: from eris.hq.igel.co.jp ([219.106.231.132]) by mx.google.com with ESMTPSA id kz4sm27111801pbc.39.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 04 Sep 2013 00:34:51 -0700 (PDT) From: Tetsuya Mukawa To: dev@dpdk.org Date: Wed, 4 Sep 2013 03:34:35 -0400 Message-Id: <1378280075-2076-1-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] pci: fix closing an unopened file descriptor X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Sep 2013 07:34:18 -0000 If CONFIG_RTE_EAL_UNBIND_PORTS is set and virtio-net is used, an unopened file descriptor will be illegally closed in the finalized phase of EAL. The fix adds a correct initial value to the file descriptor, and check it before closing it. Signed-off-by: Tetsuya Mukawa --- lib/librte_eal/linuxapp/eal/eal_pci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index c793148..7c04ba3 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -519,6 +519,8 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, dev->addr.devid = devid; dev->addr.function = function; + dev->intr_handle.fd = -1; + /* get vendor id */ rte_snprintf(filename, sizeof(filename), "%s/vendor", dirname); if (eal_parse_sysfs_value(filename, &tmp) < 0) { @@ -718,7 +720,8 @@ pci_exit_process(struct rte_pci_device *dev) RTE_LOG(ERR, EAL, "Error with munmap\n"); return -1; } - if (close(dev->intr_handle.fd) == -1){ + if ((dev->intr_handle.fd != -1) && + (close(dev->intr_handle.fd) == -1)) { RTE_LOG(ERR, EAL, "Error closing interrupt handle\n"); return -1; } -- 1.8.3.1