Changeset 90b0e28 in rtems


Ignore:
Timestamp:
Nov 26, 2014, 8:53:52 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
fdd1e20
Parents:
d6f0ca64
git-author:
Sebastian Huber <sebastian.huber@…> (11/26/14 08:53:52)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/26/14 08:56:01)
Message:

i2c: Do not close file descriptor 0 if open fails

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/dev/i2c/i2c-dev.c

    rd6f0ca64 r90b0e28  
    219219)
    220220{
    221   int fd;
    222221  int rv;
    223222
    224   fd = open(bus_path, O_RDWR);
    225   if (fd < 0) {
     223  dev->bus_fd = open(bus_path, O_RDWR);
     224  if (dev->bus_fd < 0) {
    226225    (*destroy)(dev);
     226
    227227    return -1;
    228228  }
    229229
    230   rv = ioctl(fd, I2C_BUS_GET_CONTROL, &dev->bus);
     230  rv = ioctl(dev->bus_fd, I2C_BUS_GET_CONTROL, &dev->bus);
    231231  if (rv != 0) {
    232     (void) close(fd);
    233232    (*destroy)(dev);
     233
    234234    return -1;
    235235  }
     
    241241  dev->get_block_size = i2c_dev_get_block_size_default;
    242242  dev->destroy = destroy;
    243   dev->bus_fd = fd;
    244243  dev->address = address;
    245244
     
    252251
    253252  rv = close(dev->bus_fd);
    254   _Assert(rv == 0);
     253  _Assert(dev->bus_fd < 0 || rv == 0);
    255254  (void) rv;
    256255}
Note: See TracChangeset for help on using the changeset viewer.