forked from nuttx/nuttx-update
wireless/bluetooth: Fix an attempt to use an uninitialized semaphore in the IOCTL logic.
This commit is contained in:
parent
4eaa2b8306
commit
0a8dd2a778
1 changed files with 36 additions and 14 deletions
|
@ -223,13 +223,20 @@ static int btnet_scan_result(FAR struct bt_scanresponse_s *result,
|
||||||
|
|
||||||
wlinfo("Scanning? %s\n", g_scanstate.bs_scanning ? "YES" : "NO");
|
wlinfo("Scanning? %s\n", g_scanstate.bs_scanning ? "YES" : "NO");
|
||||||
|
|
||||||
/* Get exclusive access to the scan data */
|
/* Get exclusive access to the scan data while we are actively scanning.
|
||||||
|
* The semaphore is uninitialized in other cases.
|
||||||
|
*/
|
||||||
|
|
||||||
ret = nxsem_wait(&g_scanstate.bs_exclsem);
|
if (g_scanstate.bs_scanning)
|
||||||
if (ret < 0)
|
{
|
||||||
{
|
/* Get exclusive access to the scan data */
|
||||||
DEBUGASSERT(ret == -EINTR || ret == -ECANCELED);
|
|
||||||
return ret;
|
ret = nxsem_wait(&g_scanstate.bs_exclsem);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
DEBUGASSERT(ret == -EINTR || ret == -ECANCELED);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy all available results */
|
/* Copy all available results */
|
||||||
|
@ -257,7 +264,12 @@ static int btnet_scan_result(FAR struct bt_scanresponse_s *result,
|
||||||
}
|
}
|
||||||
|
|
||||||
g_scanstate.bs_head = head;
|
g_scanstate.bs_head = head;
|
||||||
nxsem_post(&g_scanstate.bs_exclsem);
|
|
||||||
|
if (g_scanstate.bs_scanning)
|
||||||
|
{
|
||||||
|
nxsem_post(&g_scanstate.bs_exclsem);
|
||||||
|
}
|
||||||
|
|
||||||
return nrsp;
|
return nrsp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,13 +409,18 @@ static int btnet_discover_result(FAR struct bt_discresonse_s *result,
|
||||||
|
|
||||||
wlinfo("Discovering? %s\n", g_discoverstate.bd_discovering ? "YES" : "NO");
|
wlinfo("Discovering? %s\n", g_discoverstate.bd_discovering ? "YES" : "NO");
|
||||||
|
|
||||||
/* Get exclusive access to the discovery data */
|
/* Get exclusive access to the discovery data while we are actively
|
||||||
|
* discovering. The semaphore is uninitialized in other cases.
|
||||||
|
*/
|
||||||
|
|
||||||
ret = nxsem_wait(&g_discoverstate.bd_exclsem);
|
if (g_discoverstate.bd_discovering)
|
||||||
if (ret < 0)
|
{
|
||||||
{
|
ret = nxsem_wait(&g_discoverstate.bd_exclsem);
|
||||||
DEBUGASSERT(ret == -EINTR || ret == -ECANCELED);
|
if (ret < 0)
|
||||||
return ret;
|
{
|
||||||
|
DEBUGASSERT(ret == -EINTR || ret == -ECANCELED);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy all available results */
|
/* Copy all available results */
|
||||||
|
@ -427,7 +444,12 @@ static int btnet_discover_result(FAR struct bt_discresonse_s *result,
|
||||||
}
|
}
|
||||||
|
|
||||||
g_discoverstate.bd_head = head;
|
g_discoverstate.bd_head = head;
|
||||||
nxsem_post(&g_discoverstate.bd_exclsem);
|
|
||||||
|
if (g_discoverstate.bd_discovering)
|
||||||
|
{
|
||||||
|
nxsem_post(&g_discoverstate.bd_exclsem);
|
||||||
|
}
|
||||||
|
|
||||||
return nrsp;
|
return nrsp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue