From: Konrad Kuchciak Date: Fri, 19 Feb 2021 11:16:18 +0000 (+0100) Subject: gdbus: Check pointer before dereference X-Git-Tag: submit/tizen/20210219.120309^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4a152f987ee1f1463f5a85d56fe61f5ca7513f8e;p=platform%2Fcore%2Fapi%2Fperipheral-io.git gdbus: Check pointer before dereference Change-Id: I2093875c5de833536573a16af7afb23af9629753 --- diff --git a/src/gdbus/peripheral_gdbus_adc.c b/src/gdbus/peripheral_gdbus_adc.c index 4ef8ed3..30cc9b4 100644 --- a/src/gdbus/peripheral_gdbus_adc.c +++ b/src/gdbus/peripheral_gdbus_adc.c @@ -39,8 +39,10 @@ static int __adc_proxy_init(void) &error); if (adc_proxy == NULL) { - _E("Failed to create adc proxy : %s", error->message); - g_error_free(error); + if (error) { + _E("Failed to create adc proxy : %s", error->message); + g_error_free(error); + } return PERIPHERAL_ERROR_IO_ERROR; } diff --git a/src/gdbus/peripheral_gdbus_gpio.c b/src/gdbus/peripheral_gdbus_gpio.c index dcc9ff2..e38b9b2 100644 --- a/src/gdbus/peripheral_gdbus_gpio.c +++ b/src/gdbus/peripheral_gdbus_gpio.c @@ -41,8 +41,10 @@ static int __gpio_proxy_init(void) &error); if (gpio_proxy == NULL) { - _E("Failed to create gpio proxy : %s", error->message); - g_error_free(error); + if (error) { + _E("Failed to create gpio proxy : %s", error->message); + g_error_free(error); + } return PERIPHERAL_ERROR_IO_ERROR; } diff --git a/src/gdbus/peripheral_gdbus_i2c.c b/src/gdbus/peripheral_gdbus_i2c.c index c2fb06f..f410f3e 100644 --- a/src/gdbus/peripheral_gdbus_i2c.c +++ b/src/gdbus/peripheral_gdbus_i2c.c @@ -39,8 +39,10 @@ static int __i2c_proxy_init(void) &error); if (i2c_proxy == NULL) { - _E("Failed to create i2c proxy : %s", error->message); - g_error_free(error); + if (error) { + _E("Failed to create i2c proxy : %s", error->message); + g_error_free(error); + } return PERIPHERAL_ERROR_IO_ERROR; } diff --git a/src/gdbus/peripheral_gdbus_pwm.c b/src/gdbus/peripheral_gdbus_pwm.c index 71a7344..74fae2c 100644 --- a/src/gdbus/peripheral_gdbus_pwm.c +++ b/src/gdbus/peripheral_gdbus_pwm.c @@ -42,8 +42,10 @@ static int __pwm_proxy_init(void) &error); if (pwm_proxy == NULL) { - _E("Failed to create pwm proxy : %s", error->message); - g_error_free(error); + if (error) { + _E("Failed to create pwm proxy : %s", error->message); + g_error_free(error); + } return PERIPHERAL_ERROR_IO_ERROR; } diff --git a/src/gdbus/peripheral_gdbus_spi.c b/src/gdbus/peripheral_gdbus_spi.c index 2861d52..9fcf339 100644 --- a/src/gdbus/peripheral_gdbus_spi.c +++ b/src/gdbus/peripheral_gdbus_spi.c @@ -39,8 +39,10 @@ static int __spi_proxy_init(void) &error); if (spi_proxy == NULL) { - _E("Failed to create spi proxy : %s", error->message); - g_error_free(error); + if (error) { + _E("Failed to create spi proxy : %s", error->message); + g_error_free(error); + } return PERIPHERAL_ERROR_IO_ERROR; } diff --git a/src/gdbus/peripheral_gdbus_uart.c b/src/gdbus/peripheral_gdbus_uart.c index 3376dff..86f7575 100644 --- a/src/gdbus/peripheral_gdbus_uart.c +++ b/src/gdbus/peripheral_gdbus_uart.c @@ -39,8 +39,10 @@ static int __uart_proxy_init(void) &error); if (uart_proxy == NULL) { - _E("Failed to create uart proxy : %s", error->message); - g_error_free(error); + if (error) { + _E("Failed to create uart proxy : %s", error->message); + g_error_free(error); + } return PERIPHERAL_ERROR_IO_ERROR; }