pio: don't close fd if it's value is negative 99/199399/2 accepted/tizen_5.5_unified_mobile_hotfix accepted/tizen_5.5_unified_wearable_hotfix tizen_5.5_mobile_hotfix tizen_5.5_tv tizen_5.5_wearable_hotfix accepted/tizen/5.5/unified/20191031.021436 accepted/tizen/5.5/unified/mobile/hotfix/20201027.085723 accepted/tizen/5.5/unified/wearable/hotfix/20201027.112349 accepted/tizen/unified/20190214.154131 submit/tizen/20190213.063316 submit/tizen_5.5/20191031.000004 submit/tizen_5.5_mobile_hotfix/20201026.185104 submit/tizen_5.5_wearable_hotfix/20201026.184304 tizen_5.5.m2_release
authorKonrad Kuchciak <k.kuchciak@samsung.com>
Mon, 11 Feb 2019 07:09:35 +0000 (08:09 +0100)
committerKonrad Kuchciak <k.kuchciak@samsung.com>
Tue, 12 Feb 2019 10:59:39 +0000 (11:59 +0100)
Additionaly return if fd open failed.

Change-Id: Ica183a00a265a499eb2e09a864062877ef8847fa
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
src/interface/peripheral_interface_adc.c
src/interface/peripheral_interface_i2c.c
src/interface/peripheral_interface_spi.c
src/interface/peripheral_interface_uart.c

index a65a982136bc7a7e32a1cdddf67f172d36c26730..623ed7453d49835f877b4b7ec7373d642565b573 100644 (file)
@@ -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;
 }
index 4a06dbc65656d9c19b3e76325f514d89f6cd1e64..efcb32b46dd3715eb1f76b96afe4a7a3c3afda75 100644 (file)
@@ -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;
 }
index 16fea9b949e6b2af28548c7afc7ba8288e65d2b0..c24d04be7a9f2742704ed8a372db8736b8067af9 100644 (file)
@@ -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;
 }
index cdfe167f1adb3f0fa9efee950bc8637891b28eba..f650b42b3755e34582a47ac01c015771112c7925 100644 (file)
@@ -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;
 }