[bugfix][T108][bug-view-1467]【uart】【gsw】 Calling gsw_uart_flush and gsw_uart_close when they are not initialized will result in Segmentation faults
Only Configure: No
Affected branch: GSW_V1453
Affected module: UART
Is it affected on IC: only ASR
Self-test: yes
Doc Update: no
Change-Id: I4571ff3e08d87fa9f7aca7cc3db565124c2bffff
diff --git a/mbtk/libgsw_lib/gsw_uart_interface.c b/mbtk/libgsw_lib/gsw_uart_interface.c
index 0544d16..d16fa69 100755
--- a/mbtk/libgsw_lib/gsw_uart_interface.c
+++ b/mbtk/libgsw_lib/gsw_uart_interface.c
@@ -305,6 +305,8 @@
void gsw_uart_flush(int fd)
{
+ if (handle())
+ return;
if (tcflush(fd, TCIOFLUSH) < 0)
{
LOGE("flush fail\n");
@@ -410,6 +412,8 @@
void gsw_uart_close(int fd)
{
+ if (handle())
+ return;
if (fd <= 0)
LOGE("fd = %d fail\n",fd);
//return GSW_HAL_NORMAL_FAIL;