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,6 +223,12 @@ static int btnet_scan_result(FAR struct bt_scanresponse_s *result,
|
|||
|
||||
wlinfo("Scanning? %s\n", g_scanstate.bs_scanning ? "YES" : "NO");
|
||||
|
||||
/* Get exclusive access to the scan data while we are actively scanning.
|
||||
* The semaphore is uninitialized in other cases.
|
||||
*/
|
||||
|
||||
if (g_scanstate.bs_scanning)
|
||||
{
|
||||
/* Get exclusive access to the scan data */
|
||||
|
||||
ret = nxsem_wait(&g_scanstate.bs_exclsem);
|
||||
|
@ -231,6 +237,7 @@ static int btnet_scan_result(FAR struct bt_scanresponse_s *result,
|
|||
DEBUGASSERT(ret == -EINTR || ret == -ECANCELED);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy all available results */
|
||||
|
||||
|
@ -257,7 +264,12 @@ static int btnet_scan_result(FAR struct bt_scanresponse_s *result,
|
|||
}
|
||||
|
||||
g_scanstate.bs_head = head;
|
||||
|
||||
if (g_scanstate.bs_scanning)
|
||||
{
|
||||
nxsem_post(&g_scanstate.bs_exclsem);
|
||||
}
|
||||
|
||||
return nrsp;
|
||||
}
|
||||
|
||||
|
@ -397,14 +409,19 @@ static int btnet_discover_result(FAR struct bt_discresonse_s *result,
|
|||
|
||||
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.
|
||||
*/
|
||||
|
||||
if (g_discoverstate.bd_discovering)
|
||||
{
|
||||
ret = nxsem_wait(&g_discoverstate.bd_exclsem);
|
||||
if (ret < 0)
|
||||
{
|
||||
DEBUGASSERT(ret == -EINTR || ret == -ECANCELED);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy all available results */
|
||||
|
||||
|
@ -427,7 +444,12 @@ static int btnet_discover_result(FAR struct bt_discresonse_s *result,
|
|||
}
|
||||
|
||||
g_discoverstate.bd_head = head;
|
||||
|
||||
if (g_discoverstate.bd_discovering)
|
||||
{
|
||||
nxsem_post(&g_discoverstate.bd_exclsem);
|
||||
}
|
||||
|
||||
return nrsp;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue