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:
zhanghongyu
2026-04-13 14:35:59 +08:00
committed by Alan C. Assis
parent 4257c55eeb
commit a0b8969636
+2 -2
View File
@@ -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
{