Bluetooth: Mesh: Fix dereferencing before null pointer check

Don't dereference pointer until it is checked on NULL.

Fixes: #66805
Coverity-CID: 338098

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit is contained in:
Pavel Vasilyev 2024-01-12 11:30:23 +01:00 committed by David Leach
commit 27b1f4eb7f

View file

@ -167,13 +167,15 @@ static bool push_msg_from_delayable_msgs(void)
sys_snode_t *node; sys_snode_t *node;
struct delayable_msg_chunk *chunk; struct delayable_msg_chunk *chunk;
struct delayable_msg_ctx *msg = peek_pending_msg(); struct delayable_msg_ctx *msg = peek_pending_msg();
uint16_t len = msg->len; uint16_t len;
int err; int err;
if (!msg) { if (!msg) {
return false; return false;
} }
len = msg->len;
NET_BUF_SIMPLE_DEFINE(buf, BT_MESH_TX_SDU_MAX); NET_BUF_SIMPLE_DEFINE(buf, BT_MESH_TX_SDU_MAX);
SYS_SLIST_FOR_EACH_NODE(&msg->chunks, node) { SYS_SLIST_FOR_EACH_NODE(&msg->chunks, node) {