mesh: Fix regression error in HB subscription set
authorInga Stotland <inga.stotland@intel.com>
Wed, 18 Nov 2020 19:56:00 +0000 (11:56 -0800)
committerAbhay Agarwal <ay.agarwal@samsung.com>
Mon, 28 Dec 2020 06:20:04 +0000 (11:50 +0530)
This fixes a regression introduced in commit c77bb848a9fb
("mesh: Refactor heartbeat pub/sub"):
Heartbeat subscription should be enabled unless either source or
destination are unassigned addresses or period log is zero.

Also, decrement ref count on group destination address if period log
is zero since the subscription is not supposed to be processed.

Change-Id: I981784d5e260e90dce022ee8785d3d1b47348e57
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
mesh/net.c

index 07c6e55..68b2503 100644 (file)
@@ -3580,16 +3580,21 @@ int mesh_net_set_heartbeat_sub(struct mesh_net *net, uint16_t src, uint16_t dst,
                sub->max_hops = 0;
 
        } else if (!period_log && src == sub->src && dst == sub->dst) {
+               if (IS_GROUP(sub->dst))
+                       mesh_net_dst_unreg(net, sub->dst);
+
                /* Preserve collected data, but disable */
                sub->enabled = false;
                sub->period = 0;
 
-       } else if (sub->dst != dst) {
-               if (IS_GROUP(sub->dst))
-                       mesh_net_dst_unreg(net, sub->dst);
+       } else {
+               if (sub->dst != dst) {
+                       if (IS_GROUP(sub->dst))
+                               mesh_net_dst_unreg(net, sub->dst);
 
-               if (IS_GROUP(dst))
-                       mesh_net_dst_reg(net, dst);
+                       if (IS_GROUP(dst))
+                               mesh_net_dst_reg(net, dst);
+               }
 
                sub->enabled = !!period_log;
                sub->src = src;