From c8909e00183e6fa1969ecfc2ee1b8168288dea61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Narajowski?= Date: Thu, 26 Jul 2018 13:39:54 +0200 Subject: [PATCH] mesh: Fix a possible memory leak --- nimble/host/mesh/src/access.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/nimble/host/mesh/src/access.c b/nimble/host/mesh/src/access.c index b06234a46..12e3bdec9 100644 --- a/nimble/host/mesh/src/access.c +++ b/nimble/host/mesh/src/access.c @@ -676,21 +676,25 @@ int bt_mesh_model_publish(struct bt_mesh_model *model) BT_DBG(""); if (!pub) { - return -ENOTSUP; + err = -ENOTSUP; + goto done; } if (pub->addr == BT_MESH_ADDR_UNASSIGNED) { - return -EADDRNOTAVAIL; + err = -EADDRNOTAVAIL; + goto done; } key = bt_mesh_app_key_find(pub->key); if (!key) { - return -EADDRNOTAVAIL; + err = -EADDRNOTAVAIL; + goto done; } if (pub->msg->om_len + 4 > BT_MESH_TX_SDU_MAX) { BT_ERR("Message does not fit maximum SDU size"); - return -EMSGSIZE; + err = -EMSGSIZE; + goto done; } if (pub->count) { @@ -719,6 +723,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model) pub->count = 0; } +done: os_mbuf_free_chain(sdu); return err; }