All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
To: Tetsuya Mukawa <mukawa-AlSX/UN32fvPDbFq/vQRIQ@public.gmane.org>
Cc: dev-VfR2kkLFssw@public.gmane.org
Subject: Re: [PATCH] pci: fix closing an unopened file descriptor
Date: Thu, 12 Sep 2013 17:28:46 +0200	[thread overview]
Message-ID: <201309121728.46471.thomas.monjalon@6wind.com> (raw)
In-Reply-To: <1378280075-2076-1-git-send-email-mukawa-AlSX/UN32fvPDbFq/vQRIQ@public.gmane.org>

04/09/2013 09:34, Tetsuya Mukawa :
> 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 <mukawa-AlSX/UN32fvPDbFq/vQRIQ@public.gmane.org>

Thanks for the patch.

I have reproduced the issue only once.
It seems that fd 0 is open most of the time.

But the patch seems OK so I applied it with light modifications:

---

pci: fix closing an unopened file descriptor
    
If CONFIG_RTE_EAL_UNBIND_PORTS is set and a non Intel PMD 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 <mukawa-AlSX/UN32fvPDbFq/vQRIQ@public.gmane.org>
Acked-by: Thomas Monjalon <thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>

--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -514,6 +514,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t 
bus,
 	}
 
 	memset(dev, 0, sizeof(*dev));
+	dev->intr_handle.fd = -1;
 	dev->addr.domain = domain;
 	dev->addr.bus = bus;
 	dev->addr.devid = devid;
@@ -718,7 +719,7 @@ 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;
 	}

      parent reply	other threads:[~2013-09-12 15:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-04  7:34 [PATCH] pci: fix closing an unopened file descriptor Tetsuya Mukawa
     [not found] ` <1378280075-2076-1-git-send-email-mukawa-AlSX/UN32fvPDbFq/vQRIQ@public.gmane.org>
2013-09-04  7:38   ` Tetsuya.Mukawa
2013-09-12 15:28   ` Thomas Monjalon [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201309121728.46471.thomas.monjalon@6wind.com \
    --to=thomas.monjalon-pdr9zngts4eavxtiumwx3w@public.gmane.org \
    --cc=dev-VfR2kkLFssw@public.gmane.org \
    --cc=mukawa-AlSX/UN32fvPDbFq/vQRIQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.