summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonrad Kuchciak <k.kuchciak@samsung.com>2019-02-11 08:09:35 +0100
committerKonrad Kuchciak <k.kuchciak@samsung.com>2019-02-12 11:59:39 +0100
commitda479b98a011748f82b66bf55b0eb0dd651e1fbf (patch)
tree4b88bedc42481e16254ee514c9b234cc363f0bf9
parent70e51fcc30b715faabb6d2e950f9886b9f2c86d8 (diff)
downloadperipheral-bus-tizen_5.5_mobile_hotfix.tar.gz
peripheral-bus-tizen_5.5_mobile_hotfix.tar.bz2
peripheral-bus-tizen_5.5_mobile_hotfix.zip
Additionaly return if fd open failed. Change-Id: Ica183a00a265a499eb2e09a864062877ef8847fa Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
-rw-r--r--src/interface/peripheral_interface_adc.c4
-rw-r--r--src/interface/peripheral_interface_i2c.c4
-rw-r--r--src/interface/peripheral_interface_spi.c4
-rw-r--r--src/interface/peripheral_interface_uart.c4
4 files changed, 12 insertions, 4 deletions
diff --git a/src/interface/peripheral_interface_adc.c b/src/interface/peripheral_interface_adc.c
index a65a982..623ed74 100644
--- a/src/interface/peripheral_interface_adc.c
+++ b/src/interface/peripheral_interface_adc.c
@@ -51,6 +51,7 @@ int peripheral_interface_adc_fd_list_create(int device, int channel, GUnixFDList
ret = __peripheral_interface_adc_fd_open(device, channel, &fd);
if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to open adc fd");
+ goto out;
}
list = g_unix_fd_list_new();
@@ -66,7 +67,8 @@ int peripheral_interface_adc_fd_list_create(int device, int channel, GUnixFDList
*list_out = list;
out:
- close(fd);
+ if (fd >= 0)
+ close(fd);
return ret;
}
diff --git a/src/interface/peripheral_interface_i2c.c b/src/interface/peripheral_interface_i2c.c
index 4a06dbc..efcb32b 100644
--- a/src/interface/peripheral_interface_i2c.c
+++ b/src/interface/peripheral_interface_i2c.c
@@ -57,6 +57,7 @@ int peripheral_interface_i2c_fd_list_create(int bus, int address, GUnixFDList **
ret = __peripheral_interface_i2c_fd_open(bus, address, &fd);
if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to open i2c fd");
+ goto out;
}
list = g_unix_fd_list_new();
@@ -72,7 +73,8 @@ int peripheral_interface_i2c_fd_list_create(int bus, int address, GUnixFDList **
*list_out = list;
out:
- close(fd);
+ if (fd >= 0)
+ close(fd);
return ret;
}
diff --git a/src/interface/peripheral_interface_spi.c b/src/interface/peripheral_interface_spi.c
index 16fea9b..c24d04b 100644
--- a/src/interface/peripheral_interface_spi.c
+++ b/src/interface/peripheral_interface_spi.c
@@ -50,6 +50,7 @@ int peripheral_interface_spi_fd_list_create(int bus, int cs, GUnixFDList **list_
ret = __peripheral_interface_spi_fd_open(bus, cs, &fd);
if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to open spi fd");
+ goto out;
}
list = g_unix_fd_list_new();
@@ -65,7 +66,8 @@ int peripheral_interface_spi_fd_list_create(int bus, int cs, GUnixFDList **list_
*list_out = list;
out:
- close(fd);
+ if (fd >= 0)
+ close(fd);
return ret;
}
diff --git a/src/interface/peripheral_interface_uart.c b/src/interface/peripheral_interface_uart.c
index cdfe167..f650b42 100644
--- a/src/interface/peripheral_interface_uart.c
+++ b/src/interface/peripheral_interface_uart.c
@@ -65,6 +65,7 @@ int peripheral_interface_uart_fd_list_create(int port, GUnixFDList **list_out)
ret = __peripheral_interface_uart_fd_open(port, &fd);
if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to open uart fd");
+ goto out;
}
list = g_unix_fd_list_new();
@@ -80,7 +81,8 @@ int peripheral_interface_uart_fd_list_create(int port, GUnixFDList **list_out)
*list_out = list;
out:
- close(fd);
+ if (fd >= 0)
+ close(fd);
return ret;
}