mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
net/bluetooth: fix null pointer dereference in bluetooth_sendmsg
Move the NULL check for radio pointer before the DEBUGASSERT that dereferences it. Previously DEBUGASSERT(radio->r_dev.d_lltype == ...) was executed before verifying radio != NULL, which would crash when the device is not found. Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
committed by
Alan C. Assis
parent
4257c55eeb
commit
a0b8969636
@@ -284,12 +284,12 @@ static ssize_t bluetooth_sendto(FAR struct socket *psock,
|
||||
radio =
|
||||
(FAR struct radio_driver_s *)netdev_findbyindex(conn->bc_ldev + 1);
|
||||
|
||||
DEBUGASSERT(radio->r_dev.d_lltype == NET_LL_BLUETOOTH);
|
||||
|
||||
if (radio == NULL)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
DEBUGASSERT(radio->r_dev.d_lltype == NET_LL_BLUETOOTH);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user