2020-08-11 16:35:49

by Stotland, Inga

[permalink] [raw]
Subject: [PATCH BlueZ] mesh: Fix element index look up for config model subs

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


2020-08-11 16:37:22

by Gix, Brian

[permalink] [raw]
Subject: Re: [PATCH BlueZ] mesh: Fix element index look up for config model subs

Applied
On Tue, 2020-08-11 at 09:31 -0700, Inga Stotland wrote:
> 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,