[rtems commit] cpukit/dev/i2c/i2c-dev.c: Fix leak on error path
Joel Sherril
joel at rtems.org
Tue Nov 25 18:57:22 UTC 2014
Module: rtems
Branch: master
Commit: a0bf44e115c0b89f7a2c8090d3b169daad8bd543
Changeset: http://git.rtems.org/rtems/commit/?id=a0bf44e115c0b89f7a2c8090d3b169daad8bd543
Author: Joel Sherrill <joel.sherrill at oarcorp.com>
Date: Mon Nov 24 14:06:49 2014 -0600
cpukit/dev/i2c/i2c-dev.c: Fix leak on error path
Coverity ID 1255520. fd was not closed on error path.
---
cpukit/dev/i2c/i2c-dev.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/cpukit/dev/i2c/i2c-dev.c b/cpukit/dev/i2c/i2c-dev.c
index b03effd..cf1cf41 100644
--- a/cpukit/dev/i2c/i2c-dev.c
+++ b/cpukit/dev/i2c/i2c-dev.c
@@ -224,14 +224,13 @@ static int i2c_dev_do_init(
fd = open(bus_path, O_RDWR);
if (fd < 0) {
(*destroy)(dev);
-
return -1;
}
rv = ioctl(fd, I2C_BUS_GET_CONTROL, &dev->bus);
if (rv != 0) {
+ (void) close(fd);
(*destroy)(dev);
-
return -1;
}
More information about the vc
mailing list