bus: fixed a flow using a handle already freed. 53/154553/1
authorSegwon <segwon.han@samsung.com>
Tue, 10 Oct 2017 10:35:16 +0000 (19:35 +0900)
committerSegwon <segwon.han@samsung.com>
Tue, 10 Oct 2017 12:02:12 +0000 (21:02 +0900)
Change-Id: I524c0ce5db54baa44548f9b342b18d2106ef0ce2
Signed-off-by: Segwon <segwon.han@samsung.com>
src/daemon/peripheral_bus_gdbus_gpio.c
src/daemon/peripheral_bus_gdbus_i2c.c
src/daemon/peripheral_bus_gdbus_pwm.c
src/daemon/peripheral_bus_gdbus_spi.c
src/daemon/peripheral_bus_gdbus_uart.c

index fde3696f63c7282ef8e8b592baa45d53489896a1..ed531540a1397af70f78751c9d44a94bba6a2bbf 100644 (file)
@@ -42,7 +42,7 @@ gboolean handle_gpio_open(
 {
        peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
        peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
-       pb_data_h gpio_handle;
+       pb_data_h gpio_handle = NULL;
 
        if ((ret = peripheral_bus_gpio_open(pin, &gpio_handle, user_data)) < PERIPHERAL_ERROR_NONE)
                goto out;
@@ -50,6 +50,7 @@ gboolean handle_gpio_open(
        if (peripheral_bus_get_client_info(invocation, pb_data, &gpio_handle->client_info) < 0) {
                peripheral_bus_gpio_close(gpio_handle);
                ret = PERIPHERAL_ERROR_UNKNOWN;
+               gpio_handle = NULL;
                goto out;
        }
 
index fdc7b805b00f8f42963d60d713e0db5ba88273e1..37db07b3c833d6dd4c033049768b38b4b3032801 100644 (file)
@@ -43,7 +43,7 @@ gboolean handle_i2c_open(
 {
        peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
        peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-       pb_data_h i2c_handle;
+       pb_data_h i2c_handle = NULL;
 
        if ((ret = peripheral_bus_i2c_open(bus, address, &i2c_handle, user_data)) < PERIPHERAL_ERROR_NONE)
                goto out;
@@ -51,6 +51,7 @@ gboolean handle_i2c_open(
        if (peripheral_bus_get_client_info(invocation, pb_data, &i2c_handle->client_info) < 0) {
                peripheral_bus_i2c_close(i2c_handle);
                ret = PERIPHERAL_ERROR_UNKNOWN;
+               i2c_handle = NULL;
                goto out;
        }
 
index acb8e21e596c691eb2b0f9da96c56421f1ed3b84..47f0c1890b8de8149481363feb9c76426d4f6313 100644 (file)
@@ -43,7 +43,7 @@ gboolean handle_pwm_open(
 {
        peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
        peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-       pb_data_h pwm_handle;
+       pb_data_h pwm_handle = NULL;
 
        if ((ret = peripheral_bus_pwm_open(chip, pin, &pwm_handle, user_data)) <  PERIPHERAL_ERROR_NONE)
                goto out;
@@ -51,6 +51,7 @@ gboolean handle_pwm_open(
        if (peripheral_bus_get_client_info(invocation, pb_data, &pwm_handle->client_info) < 0) {
                peripheral_bus_pwm_close(pwm_handle);
                ret = PERIPHERAL_ERROR_UNKNOWN;
+               pwm_handle = NULL;
                goto out;
        }
 
index f0f9010be118d6820aa1678e4ca976c7dfcc847c..043d94bc6af18dae0c585025fb9a6c82bb101329 100644 (file)
@@ -43,7 +43,7 @@ gboolean handle_spi_open(
 {
        peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
        peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-       pb_data_h spi_handle;
+       pb_data_h spi_handle = NULL;
 
        if ((ret = peripheral_bus_spi_open(bus, cs, &spi_handle, user_data)) < PERIPHERAL_ERROR_NONE)
                goto out;
@@ -51,6 +51,7 @@ gboolean handle_spi_open(
        if (peripheral_bus_get_client_info(invocation, pb_data, &spi_handle->client_info) < 0) {
                peripheral_bus_spi_close(spi_handle);
                ret = PERIPHERAL_ERROR_UNKNOWN;
+               spi_handle = NULL;
                goto out;
        }
 
index b927ee62ea6e9c29994ab969742d1ba9afe99f80..12f346f4142b7c97783e582a78dbc0ceaa033fca 100644 (file)
@@ -42,7 +42,7 @@ gboolean handle_uart_open(
 {
        peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
        peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-       pb_data_h uart_handle;
+       pb_data_h uart_handle = NULL;
 
        if ((ret = peripheral_bus_uart_open(port, &uart_handle, user_data)) < PERIPHERAL_ERROR_NONE)
                goto out;
@@ -50,6 +50,7 @@ gboolean handle_uart_open(
        if (peripheral_bus_get_client_info(invocation, pb_data, &uart_handle->client_info) < 0) {
                peripheral_bus_uart_close(uart_handle);
                ret = PERIPHERAL_ERROR_UNKNOWN;
+               uart_handle = NULL;
                goto out;
        }