bus: fixed a flow using a handle already freed. 13/154513/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 10:35:16 +0000 (19:35 +0900)
Change-Id: Ie3596fa2db1e607d15d0c3745a872a5d4c3f067d
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 fde3696..ed53154 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 fdc7b80..37db07b 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 acb8e21..47f0c18 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 f0f9010..043d94b 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 b927ee6..12f346f 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;
        }