This is an automated email from the ASF dual-hosted git repository. naraj pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit 5e24948f0f409826cedcf8a6a1c0189024ce85cd Author: Krzysztof Kopyściński <krzysztof.kopyscin...@codecoup.pl> AuthorDate: Mon Mar 29 13:10:27 2021 +0200 mesh: Check model publish pointer before dereferencing Moves the if !(pub) check to happen before it gets used in the initialization of the message context in bt_mesh_model_publish. this is port of bba2d7b84b82ac7322898776b46727580bc39ae0 --- nimble/host/mesh/src/access.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/nimble/host/mesh/src/access.c b/nimble/host/mesh/src/access.c index da07718..d23a656 100644 --- a/nimble/host/mesh/src/access.c +++ b/nimble/host/mesh/src/access.c @@ -682,8 +682,15 @@ int bt_mesh_model_send(struct bt_mesh_model *model, int bt_mesh_model_publish(struct bt_mesh_model *model) { + int err; struct os_mbuf *sdu = NET_BUF_SIMPLE(BT_MESH_TX_SDU_MAX); struct bt_mesh_model_pub *pub = model->pub; + + if (!pub) { + err = -ENOTSUP; + goto done; + } + struct bt_mesh_msg_ctx ctx = { .addr = pub->addr, .send_ttl = pub->ttl, @@ -694,15 +701,9 @@ int bt_mesh_model_publish(struct bt_mesh_model *model) .ctx = &ctx, .src = bt_mesh_model_elem(model)->addr, }; - int err; BT_DBG(""); - if (!pub) { - err = -ENOTSUP; - goto done; - } - if (pub->addr == BT_MESH_ADDR_UNASSIGNED) { err = -EADDRNOTAVAIL; goto done;