diff mbox

[PULL,0/19] xen-2015-09-08-tag

Message ID 55F8C1B8.6060509@intel.com
State New
Headers show

Commit Message

Tiejun Chen Sept. 16, 2015, 1:11 a.m. UTC
On 9/15/2015 7:00 PM, Paolo Bonzini wrote:
>
>
> On 15/09/2015 11:55, Stefano Stabellini wrote:
>> On Mon, 14 Sep 2015, Paolo Bonzini wrote:
>>> > On 10/09/2015 12:29, Stefano Stabellini wrote:
>>>> > > +    if (lseek(config_fd, pos, SEEK_SET) != pos) {
>>>> > > +        return -errno;
>>>> > > +    }
>>>> > >      do {
>>>> > > -        rc = pread(config_fd, (uint8_t *)&val, len, pos);
>>>> > > +        rc = read(config_fd, (uint8_t *)&val, len);
>>>> > >      } while (rc < 0 && (errno == EINTR || errno == EAGAIN));
>>> >
>>> > This leaks config_fd.
>> I don't follow, it leaks config_fd where?
>
> Where lseek returns -errno (and IIRC in other places in the same function).

Do you mean we need this change?



Thanks
Tiejun

Comments

Stefano Stabellini Sept. 17, 2015, 11:47 a.m. UTC | #1
On Wed, 16 Sep 2015, Chen, Tiejun wrote:
> On 9/15/2015 7:00 PM, Paolo Bonzini wrote:
> > 
> > 
> > On 15/09/2015 11:55, Stefano Stabellini wrote:
> > > On Mon, 14 Sep 2015, Paolo Bonzini wrote:
> > > > > On 10/09/2015 12:29, Stefano Stabellini wrote:
> > > > > > > +    if (lseek(config_fd, pos, SEEK_SET) != pos) {
> > > > > > > +        return -errno;
> > > > > > > +    }
> > > > > > >      do {
> > > > > > > -        rc = pread(config_fd, (uint8_t *)&val, len, pos);
> > > > > > > +        rc = read(config_fd, (uint8_t *)&val, len);
> > > > > > >      } while (rc < 0 && (errno == EINTR || errno == EAGAIN));
> > > > >
> > > > > This leaks config_fd.
> > > I don't follow, it leaks config_fd where?
> > 
> > Where lseek returns -errno (and IIRC in other places in the same function).
> 
> Do you mean we need this change?

Yes, please send out a separate patch. Add my Acked-by.


> diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
> index 1fb71c8..7d44228 100644
> --- a/hw/pci-host/piix.c
> +++ b/hw/pci-host/piix.c
> @@ -775,15 +775,18 @@ static int host_pci_config_read(int pos, int len,
> uint32_t val)
>      }
> 
>      if (lseek(config_fd, pos, SEEK_SET) != pos) {
> +        close(config_fd);
>          return -errno;
>      }
>      do {
>          rc = read(config_fd, (uint8_t *)&val, len);
>      } while (rc < 0 && (errno == EINTR || errno == EAGAIN));
>      if (rc != len) {
> +        close(config_fd);
>          return -errno;
>      }
> 
> +    close(config_fd);
>      return 0;
>  }
> 
> 
> Thanks
> Tiejun
>
diff mbox

Patch

diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index 1fb71c8..7d44228 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -775,15 +775,18 @@  static int host_pci_config_read(int pos, int len, 
uint32_t val)
      }

      if (lseek(config_fd, pos, SEEK_SET) != pos) {
+        close(config_fd);
          return -errno;
      }
      do {
          rc = read(config_fd, (uint8_t *)&val, len);
      } while (rc < 0 && (errno == EINTR || errno == EAGAIN));
      if (rc != len) {
+        close(config_fd);
          return -errno;
      }

+    close(config_fd);
      return 0;
  }