Bluetooth: Mesh: Fix dereferencing pointer before checking for NULL

The publication context is checked for NULL in bt_mesh_model_publish()
however it was dereferenced before that. Move the assignment to
ctx.send_rel to the same place where other ctx members are set.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2020-04-02 16:39:12 +03:00 committed by Johan Hedberg
commit 329d5908a2

View file

@ -705,7 +705,6 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
struct bt_mesh_model_pub *pub = model->pub;
struct bt_mesh_app_key *key;
struct bt_mesh_msg_ctx ctx = {
.send_rel = pub->send_rel,
};
struct bt_mesh_net_tx tx = {
.ctx = &ctx,
@ -743,6 +742,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
ctx.addr = pub->addr;
ctx.send_ttl = pub->ttl;
ctx.send_rel = pub->send_rel;
ctx.net_idx = key->net_idx;
ctx.app_idx = key->app_idx;