From 0258968abdd17b8541f4e15e8bce94ef15d0c2a3 Mon Sep 17 00:00:00 2001 From: Masayuki Ishikawa Date: Tue, 15 Feb 2022 08:55:09 +0900 Subject: [PATCH] drivers: wireless: Fix gs2200m_ioctl_accept() Summary: - I received an issue report that multiwebcam in Spresense SDK 2.4.0 has a problem with the Chrome browser - Actually, the browser tries to establish 2 connections but the multiwebcam can handle only 1 connection. And if accept() for the second connection is delayed, the connection no longer exists in the gs2200m hardware - This commit fixes this issue by checking if the cid is valid or not. Impact: - gs2200m driver only Testing: - Tested with spresense:wifi_smp Signed-off-by: Masayuki Ishikawa --- drivers/wireless/gs2200m.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/drivers/wireless/gs2200m.c b/drivers/wireless/gs2200m.c index e746e6119e..f6e41c6d83 100644 --- a/drivers/wireless/gs2200m.c +++ b/drivers/wireless/gs2200m.c @@ -524,9 +524,18 @@ static void _check_pkt_q_empty(FAR struct gs2200m_dev_s *dev, char cid) while (pkt_dat) { - wlerr("=== error: found (type=%d msg[0]=%s|)\n", - pkt_dat->type, pkt_dat->msg[0]); + wlerr("=== error: found (cid=%c type=%d msg[0]=%s|)\n", + cid, pkt_dat->type, pkt_dat->msg[0]); pkt_dat = (FAR struct pkt_dat_s *)pkt_dat->dq.flink; + + if (_cid_is_set(&dev->valid_cid_bits, cid)) + { + wlerr("+++ error: cid=%c is still active !!!\n", cid); + } + + /* NOTE: force to disable the cid to remove */ + + _enable_cid(&dev->valid_cid_bits, cid, false); } _remove_all_pkt(dev, c); @@ -2536,13 +2545,20 @@ static int gs2200m_ioctl_accept(FAR struct gs2200m_dev_s *dev, uint8_t c; char s_cid; char c_cid; + int ret = OK; int n; wlinfo("+++ start: cid=%c\n", msg->cid); c = _cid_to_uint8(msg->cid); pkt_dat = (FAR struct pkt_dat_s *)dq_peek(&dev->pkt_q[c]); - ASSERT(pkt_dat); + + if (NULL == pkt_dat) + { + wlerr("*** error: cid=%c not found\n", msg->cid); + ret = -EINVAL; + goto errout; + } n = sscanf(pkt_dat->msg[0], "CONNECT %c %c", &s_cid, &c_cid); ASSERT(2 == n); @@ -2574,13 +2590,20 @@ static int gs2200m_ioctl_accept(FAR struct gs2200m_dev_s *dev, nmsg.local = 0; nmsg.cid = msg->cid; r = gs2200m_get_cstatus(dev, &nmsg); - ASSERT(TYPE_OK == r); + + if (TYPE_OK != r) + { + wlerr("*** error: cid=%c not found\n", msg->cid); + ret = -EINVAL; + goto errout; + } msg->addr = nmsg.addr; +errout: wlinfo("+++ end: type=%d (msg->cid=%c)\n", msg->type, msg->cid); - return OK; + return ret; } /****************************************************************************