Check ch_id in UIPC_Read before using it
Bug: 113495295
Test: manual
Change-Id: I4930e476b55f2745cb967cbb44edd80a9ff85b34
diff --git a/udrv/ulinux/uipc.cc b/udrv/ulinux/uipc.cc
index e2f2950..24fa711 100644
--- a/udrv/ulinux/uipc.cc
+++ b/udrv/ulinux/uipc.cc
@@ -621,15 +621,15 @@
uint32_t UIPC_Read(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id,
UNUSED_ATTR uint16_t* p_msg_evt, uint8_t* p_buf,
uint32_t len) {
- int n_read = 0;
- int fd = uipc.ch[ch_id].fd;
- struct pollfd pfd;
-
if (ch_id >= UIPC_CH_NUM) {
BTIF_TRACE_ERROR("UIPC_Read : invalid ch id %d", ch_id);
return 0;
}
+ int n_read = 0;
+ int fd = uipc.ch[ch_id].fd;
+ struct pollfd pfd;
+
if (fd == UIPC_DISCONNECTED) {
BTIF_TRACE_ERROR("UIPC_Read : channel %d closed", ch_id);
return 0;