Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp568103pxa; Tue, 11 Aug 2020 09:35:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1NMKT2cdlplwKuzA7U2yI4NZp+wCJjNfUB9rPxncjc+8LkFJBpuxc8VLt/zZEu4GhqDFt X-Received: by 2002:a17:906:3803:: with SMTP id v3mr25933102ejc.165.1597163749366; Tue, 11 Aug 2020 09:35:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597163749; cv=none; d=google.com; s=arc-20160816; b=xa+lqqSOZ3aFE1tkwoTY6yR37e7zPmA2l3n2XhcaYcsh2/GpjXzxvjBwPDSrqOBdT5 ExP0hr2o9ZpCBDqiNDLP/9IyOPi+r7XBXvYMNXXC+Gf2jPLhLDBplmj2LtMd3MOcETtA B6H+GNf5pZB5bzVW+CPMWRBgkGP+fpLU0utA5Y5jfSjyDefEedUTL7j0SVbOu2pjx2UZ B1v6amESq6j1P1za0pj+8j50HDO0fMGUILvjy2qK3/Z2EjxwcFDnv0d2sBIERnle4wBm 87QihnsGVZbBJd6vLs/TDymgNoBqIUdb+FUy2vC7QOKfgnnPn03GDXXo/OE2fYecqFw8 KtOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=aXOJZV2oqdu8Ga9bMA0VbCn87Wq52yKNRrJXmcXsH38=; b=F029qtjo3JYgLC/RUctgZYB8dzVADUj6FIdmOq/8BphpkwESUMTSSg0JcXrqTmYoxM gksGiB8+32wcOTC7+cYZgLA88Cxxi+CXGVL4W3e2JhRxaNfo1VA0lYOdywV+YRTUrEGB +8BHyEAThaDOUxdB7H8V7bRBpmddi9/k/Tn/QO3+DKC14AVmAVINxO6th5X35pouCHob yxQlZWAKGOTtBrgctOHXGvib0/5vuWHxEBy9Jgco6CQCZpmZ2aHtCfC7aYD2rOMGava3 Mv83zhWuqA3oltTY6tjJku2WZo6a0wQWtZdtsUd5xcCuwszVhVVZCSgEfbYev5Z15EBW eixA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n8si13187721ejj.649.2020.08.11.09.35.05; Tue, 11 Aug 2020 09:35:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729238AbgHKQbi (ORCPT + 99 others); Tue, 11 Aug 2020 12:31:38 -0400 Received: from mga17.intel.com ([192.55.52.151]:55308 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728862AbgHKQbh (ORCPT ); Tue, 11 Aug 2020 12:31:37 -0400 IronPort-SDR: UsA247tjODg3NCIJh7xgjKivTr9MqDQ20/ipqtreUiiJlwn6gvskyPmyl7TS3bjSk4YrEPuh1p bZaGm71gcOfQ== X-IronPort-AV: E=McAfee;i="6000,8403,9710"; a="133815955" X-IronPort-AV: E=Sophos;i="5.76,301,1592895600"; d="scan'208";a="133815955" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2020 09:31:36 -0700 IronPort-SDR: E1rAa5ZhJVqw8TldjmV/5rE7uKjqNyKr3m920gcghLRXUNmd7W5u5ph5xaDSH5DZlddOcmmVLx P4UvM9Zreq/w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,301,1592895600"; d="scan'208";a="294767768" Received: from rajkumar-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.82.230]) by orsmga006.jf.intel.com with ESMTP; 11 Aug 2020 09:31:35 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ] mesh: Fix element index look up for config model subs Date: Tue, 11 Aug 2020 09:31:34 -0700 Message-Id: <20200811163134.8561-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Use element address for looking up element index (subscription address was erroneously used to perform the lookup). --- mesh/model.c | 15 ++++++++------- mesh/model.h | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/mesh/model.c b/mesh/model.c index 690be29d5..23afb93a8 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -1402,13 +1402,13 @@ done: return MESH_STATUS_SUCCESS; } -int mesh_model_sub_get(struct mesh_node *node, uint16_t addr, uint32_t id, +int mesh_model_sub_get(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size) { int16_t n; struct mesh_model *mod; const struct l_queue_entry *entry; - int ele_idx = node_get_element_idx(node, addr); + int ele_idx = node_get_element_idx(node, ele_addr); if (ele_idx < 0) return MESH_STATUS_INVALID_ADDRESS; @@ -1454,7 +1454,7 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint16_t addr) { struct mesh_model *mod; - int status, ele_idx = node_get_element_idx(node, addr); + int status, ele_idx = node_get_element_idx(node, ele_addr); if (ele_idx < 0) return MESH_STATUS_INVALID_ADDRESS; @@ -1510,7 +1510,7 @@ int mesh_model_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint16_t addr) { struct mesh_model *mod; - int ele_idx = node_get_element_idx(node, addr); + int ele_idx = node_get_element_idx(node, ele_addr); if (ele_idx < 0) return MESH_STATUS_INVALID_ADDRESS; @@ -1567,7 +1567,7 @@ int mesh_model_sub_del(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint16_t addr) { struct mesh_model *mod; - int ele_idx = node_get_element_idx(node, addr); + int ele_idx = node_get_element_idx(node, ele_addr); if (ele_idx < 0) return MESH_STATUS_INVALID_ADDRESS; @@ -1629,10 +1629,11 @@ int mesh_model_virt_sub_del(struct mesh_node *node, uint16_t ele_addr, return MESH_STATUS_SUCCESS; } -int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id) +int mesh_model_sub_del_all(struct mesh_node *node, uint16_t ele_addr, + uint32_t id) { struct mesh_model *mod; - int ele_idx = node_get_element_idx(node, addr); + int ele_idx = node_get_element_idx(node, ele_addr); if (ele_idx < 0) return MESH_STATUS_INVALID_ADDRESS; diff --git a/mesh/model.h b/mesh/model.h index a88d25d77..147a02279 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -98,7 +98,8 @@ int mesh_model_sub_del(struct mesh_node *node, uint16_t ele_addr, uint32_t id, int mesh_model_virt_sub_del(struct mesh_node *node, uint16_t ele_addr, uint32_t id, const uint8_t *label, uint16_t *addr); -int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id); +int mesh_model_sub_del_all(struct mesh_node *node, uint16_t ele_addr, + uint32_t id); int mesh_model_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint16_t addr); int mesh_model_virt_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, -- 2.26.2