From 67ab8a31736dcabac7218076b01b9cd0a57a90ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Narajowski?= Date: Mon, 6 Jul 2020 14:53:15 +0200 Subject: [PATCH] Bluetooth: Mesh: Fix response to Provisioning PDU with invalid type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reverse the order of these checks because invalid PDU type will never be expected. If PDU type is invalid we should respond with error 0x0002 - Invalid format. Signed-off-by: MichaƂ Narajowski --- subsys/bluetooth/mesh/prov.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/subsys/bluetooth/mesh/prov.c b/subsys/bluetooth/mesh/prov.c index cd5a19bf430..62a368f9331 100644 --- a/subsys/bluetooth/mesh/prov.c +++ b/subsys/bluetooth/mesh/prov.c @@ -1064,15 +1064,15 @@ static void prov_recv(const struct prov_bearer *bearer, void *cb_data, BT_DBG("type 0x%02x len %u", type, buf->len); - if (type != PROV_FAILED && type != link.expect) { - BT_WARN("Unexpected msg 0x%02x != 0x%02x", type, link.expect); - prov_fail(PROV_ERR_UNEXP_PDU); + if (type >= ARRAY_SIZE(prov_handlers)) { + BT_ERR("Unknown provisioning PDU type 0x%02x", type); + prov_fail(PROV_ERR_NVAL_FMT); return; } - if (type >= ARRAY_SIZE(prov_handlers)) { - BT_ERR("Unknown provisioning PDU type 0x%02x", type); - prov_fail(PROV_ERR_NVAL_PDU); + if (type != PROV_FAILED && type != link.expect) { + BT_WARN("Unexpected msg 0x%02x != 0x%02x", type, link.expect); + prov_fail(PROV_ERR_UNEXP_PDU); return; }