summaryrefslogtreecommitdiff
path: root/mesh/net.c
diff options
context:
space:
mode:
authorMichaƂ Lowas-Rzechonek <michal.lowas-rzechonek@silvair.com>2020-08-06 16:21:08 +0200
committerBrian Gix <brian.gix@intel.com>2020-08-06 15:46:57 -0700
commit347117afd8e0d467224395f1ab82c9d1879e69b7 (patch)
tree6e2e52573b62e59f3e748f78f2cc81c5fc3b96a9 /mesh/net.c
parent7b25497cc8f70169cf92389e6716840b0ffeceaa (diff)
downloadbluez-347117afd8e0d467224395f1ab82c9d1879e69b7.tar.gz
mesh: Allow deleting non-existing net key
When deleting a non-existing key, first check that it doesn't exist (and return success), then verify it's not the last key we have.
Diffstat (limited to 'mesh/net.c')
-rw-r--r--mesh/net.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/mesh/net.c b/mesh/net.c
index b54c647cb..a163343cb 100644
--- a/mesh/net.c
+++ b/mesh/net.c
@@ -800,15 +800,15 @@ int mesh_net_del_key(struct mesh_net *net, uint16_t idx)
if (!net)
return MESH_STATUS_UNSPECIFIED_ERROR;
- /* Cannot remove primary key */
- if (l_queue_length(net->subnets) <= 1)
- return MESH_STATUS_CANNOT_REMOVE;
-
subnet = l_queue_find(net->subnets, match_key_index,
L_UINT_TO_PTR(idx));
if (!subnet)
return MESH_STATUS_SUCCESS;
+ /* Cannot remove primary key */
+ if (l_queue_length(net->subnets) <= 1)
+ return MESH_STATUS_CANNOT_REMOVE;
+
/* Delete associated app keys */
appkey_delete_bound_keys(net, idx);