Linux-Bluetooth Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH BlueZ v2 0/4] mesh: Static Analysis clean-up
@ 2020-05-22 21:13 Brian Gix
  2020-05-22 21:13 ` [PATCH BlueZ v2 1/4] mesh: Fix using uninitialized bytes Brian Gix
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Brian Gix @ 2020-05-22 21:13 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: inga.stotland, brian.gix

This patchset fixes static analysis identified issues in the
mesh daemon.

v2: Clean-up PB-ADV queue


Brian Gix (4):
  mesh: Fix using uninitialized bytes
  mesh: Fix leaked mesh_net allocation
  mesh: Fix leaked message reference
  mesh: Destroy PB-ADV queue when provisioning done

 mesh/crypto.c  | 1 +
 mesh/manager.c | 3 ++-
 mesh/node.c    | 4 ++--
 mesh/pb-adv.c  | 5 +++++
 4 files changed, 10 insertions(+), 3 deletions(-)

-- 
2.25.4


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH BlueZ v2 1/4] mesh: Fix using uninitialized bytes
  2020-05-22 21:13 [PATCH BlueZ v2 0/4] mesh: Static Analysis clean-up Brian Gix
@ 2020-05-22 21:13 ` Brian Gix
  2020-05-22 21:13 ` [PATCH BlueZ v2 2/4] mesh: Fix leaked mesh_net allocation Brian Gix
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Brian Gix @ 2020-05-22 21:13 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: inga.stotland, brian.gix

Fixes two problems found with static analysis
---
 mesh/crypto.c | 1 +
 mesh/node.c   | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/mesh/crypto.c b/mesh/crypto.c
index 99536594b..70b96c51b 100644
--- a/mesh/crypto.c
+++ b/mesh/crypto.c
@@ -553,6 +553,7 @@ bool mesh_crypto_packet_build(bool ctl, uint8_t ttl,
 	if (seq > SEQ_MASK)
 		return false;
 
+	packet[0] = 0;
 	l_put_be32(seq, packet + 1);
 	packet[1] = (ctl ? CTL : 0) | (ttl & TTL_MASK);
 
diff --git a/mesh/node.c b/mesh/node.c
index dd28dfd77..49ba7c885 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -1596,6 +1596,8 @@ static void get_managed_objects_cb(struct l_dbus_message *msg, void *user_data)
 		/* Generate device and primary network keys */
 		l_getrandom(dev_key, sizeof(dev_key));
 		l_getrandom(net_key.old_key, sizeof(net_key.old_key));
+		memcpy(net_key.new_key, net_key.old_key,
+						sizeof(net_key.old_key));
 		net_key.net_idx = PRIMARY_NET_IDX;
 		net_key.phase = KEY_REFRESH_PHASE_NONE;
 
-- 
2.25.4


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH BlueZ v2 2/4] mesh: Fix leaked mesh_net allocation
  2020-05-22 21:13 [PATCH BlueZ v2 0/4] mesh: Static Analysis clean-up Brian Gix
  2020-05-22 21:13 ` [PATCH BlueZ v2 1/4] mesh: Fix using uninitialized bytes Brian Gix
@ 2020-05-22 21:13 ` Brian Gix
  2020-05-22 23:37   ` [BlueZ,v2,2/4] " bluez.test.bot
  2020-05-22 21:13 ` [PATCH BlueZ v2 3/4] mesh: Fix leaked message reference Brian Gix
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Brian Gix @ 2020-05-22 21:13 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: inga.stotland, brian.gix

---
 mesh/node.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/mesh/node.c b/mesh/node.c
index 49ba7c885..db888d27c 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -1313,8 +1313,6 @@ static bool add_local_node(struct mesh_node *node, uint16_t unicast, bool kr,
 				bool ivu, uint32_t iv_idx, uint8_t dev_key[16],
 				uint16_t net_key_idx, uint8_t net_key[16])
 {
-	node->net = mesh_net_new(node);
-
 	if (!nodes)
 		nodes = l_queue_new();
 
-- 
2.25.4


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH BlueZ v2 3/4] mesh: Fix leaked message reference
  2020-05-22 21:13 [PATCH BlueZ v2 0/4] mesh: Static Analysis clean-up Brian Gix
  2020-05-22 21:13 ` [PATCH BlueZ v2 1/4] mesh: Fix using uninitialized bytes Brian Gix
  2020-05-22 21:13 ` [PATCH BlueZ v2 2/4] mesh: Fix leaked mesh_net allocation Brian Gix
@ 2020-05-22 21:13 ` Brian Gix
  2020-05-22 23:37   ` [BlueZ,v2,3/4] " bluez.test.bot
  2020-05-22 21:13 ` [PATCH BlueZ v2 4/4] mesh: Destroy PB-ADV queue when provisioning done Brian Gix
  2020-05-25 14:15 ` [PATCH BlueZ v2 0/4] mesh: Static Analysis clean-up Gix, Brian
  4 siblings, 1 reply; 9+ messages in thread
From: Brian Gix @ 2020-05-22 21:13 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: inga.stotland, brian.gix

---
 mesh/manager.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mesh/manager.c b/mesh/manager.c
index 0242bb9e9..a7383e4d5 100644
--- a/mesh/manager.c
+++ b/mesh/manager.c
@@ -228,6 +228,7 @@ static void add_start(void *user_data, int err)
 				"Failed to start provisioning initiator");
 
 	l_dbus_send(dbus_get_bus(), reply);
+	l_dbus_message_unref(add_pending->msg);
 
 	add_pending->msg = NULL;
 }
@@ -264,7 +265,6 @@ static struct l_dbus_message *add_node_call(struct l_dbus *dbus,
 	/* Invoke Prov Initiator */
 
 	add_pending = l_new(struct add_data, 1);
-	add_pending->msg = l_dbus_message_ref(msg);
 	memcpy(add_pending->uuid, uuid, 16);
 	add_pending->node = node;
 	add_pending->agent = node_get_agent(node);
@@ -277,6 +277,7 @@ static struct l_dbus_message *add_node_call(struct l_dbus *dbus,
 		goto fail;
 	}
 
+	add_pending->msg = l_dbus_message_ref(msg);
 	initiator_start(PB_ADV, uuid, 99, 60, add_pending->agent, add_start,
 				add_data_get, add_cmplt, node, add_pending);
 
-- 
2.25.4


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH BlueZ v2 4/4] mesh: Destroy PB-ADV queue when provisioning done
  2020-05-22 21:13 [PATCH BlueZ v2 0/4] mesh: Static Analysis clean-up Brian Gix
                   ` (2 preceding siblings ...)
  2020-05-22 21:13 ` [PATCH BlueZ v2 3/4] mesh: Fix leaked message reference Brian Gix
@ 2020-05-22 21:13 ` Brian Gix
  2020-05-22 23:37   ` [BlueZ,v2,4/4] " bluez.test.bot
  2020-05-25 14:15 ` [PATCH BlueZ v2 0/4] mesh: Static Analysis clean-up Gix, Brian
  4 siblings, 1 reply; 9+ messages in thread
From: Brian Gix @ 2020-05-22 21:13 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: inga.stotland, brian.gix

---
 mesh/pb-adv.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/mesh/pb-adv.c b/mesh/pb-adv.c
index 291d92651..c1316ed1b 100644
--- a/mesh/pb-adv.c
+++ b/mesh/pb-adv.c
@@ -560,4 +560,9 @@ void pb_adv_unreg(void *user_data)
 	send_close_ind(session, 0);
 	l_queue_remove(pb_sessions, session);
 	l_free(session);
+
+	if (!l_queue_length(pb_sessions)) {
+		l_queue_destroy(pb_sessions, l_free);
+		pb_sessions = NULL;
+	}
 }
-- 
2.25.4


^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [BlueZ,v2,2/4] mesh: Fix leaked mesh_net allocation
  2020-05-22 21:13 ` [PATCH BlueZ v2 2/4] mesh: Fix leaked mesh_net allocation Brian Gix
@ 2020-05-22 23:37   ` bluez.test.bot
  0 siblings, 0 replies; 9+ messages in thread
From: bluez.test.bot @ 2020-05-22 23:37 UTC (permalink / raw)
  To: linux-bluetooth, brian.gix


[-- Attachment #1: Type: text/plain, Size: 350 bytes --]


This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While we are preparing for reviewing the patches, we found the following
issue/warning.

Test Result:
checkgitlint Failed

Outputs:
3: B6 Body message is missing



---
Regards,
Linux Bluetooth

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [BlueZ,v2,3/4] mesh: Fix leaked message reference
  2020-05-22 21:13 ` [PATCH BlueZ v2 3/4] mesh: Fix leaked message reference Brian Gix
@ 2020-05-22 23:37   ` bluez.test.bot
  0 siblings, 0 replies; 9+ messages in thread
From: bluez.test.bot @ 2020-05-22 23:37 UTC (permalink / raw)
  To: linux-bluetooth, brian.gix


[-- Attachment #1: Type: text/plain, Size: 350 bytes --]


This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While we are preparing for reviewing the patches, we found the following
issue/warning.

Test Result:
checkgitlint Failed

Outputs:
3: B6 Body message is missing



---
Regards,
Linux Bluetooth

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [BlueZ,v2,4/4] mesh: Destroy PB-ADV queue when provisioning done
  2020-05-22 21:13 ` [PATCH BlueZ v2 4/4] mesh: Destroy PB-ADV queue when provisioning done Brian Gix
@ 2020-05-22 23:37   ` bluez.test.bot
  0 siblings, 0 replies; 9+ messages in thread
From: bluez.test.bot @ 2020-05-22 23:37 UTC (permalink / raw)
  To: linux-bluetooth, brian.gix


[-- Attachment #1: Type: text/plain, Size: 350 bytes --]


This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While we are preparing for reviewing the patches, we found the following
issue/warning.

Test Result:
checkgitlint Failed

Outputs:
3: B6 Body message is missing



---
Regards,
Linux Bluetooth

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH BlueZ v2 0/4] mesh: Static Analysis clean-up
  2020-05-22 21:13 [PATCH BlueZ v2 0/4] mesh: Static Analysis clean-up Brian Gix
                   ` (3 preceding siblings ...)
  2020-05-22 21:13 ` [PATCH BlueZ v2 4/4] mesh: Destroy PB-ADV queue when provisioning done Brian Gix
@ 2020-05-25 14:15 ` Gix, Brian
  4 siblings, 0 replies; 9+ messages in thread
From: Gix, Brian @ 2020-05-25 14:15 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Stotland, Inga

Patchset Applied
On Fri, 2020-05-22 at 14:13 -0700, Brian Gix wrote:
> This patchset fixes static analysis identified issues in the
> mesh daemon.
> 
> v2: Clean-up PB-ADV queue
> 
> 
> Brian Gix (4):
>   mesh: Fix using uninitialized bytes
>   mesh: Fix leaked mesh_net allocation
>   mesh: Fix leaked message reference
>   mesh: Destroy PB-ADV queue when provisioning done
> 
>  mesh/crypto.c  | 1 +
>  mesh/manager.c | 3 ++-
>  mesh/node.c    | 4 ++--
>  mesh/pb-adv.c  | 5 +++++
>  4 files changed, 10 insertions(+), 3 deletions(-)
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, back to index

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-22 21:13 [PATCH BlueZ v2 0/4] mesh: Static Analysis clean-up Brian Gix
2020-05-22 21:13 ` [PATCH BlueZ v2 1/4] mesh: Fix using uninitialized bytes Brian Gix
2020-05-22 21:13 ` [PATCH BlueZ v2 2/4] mesh: Fix leaked mesh_net allocation Brian Gix
2020-05-22 23:37   ` [BlueZ,v2,2/4] " bluez.test.bot
2020-05-22 21:13 ` [PATCH BlueZ v2 3/4] mesh: Fix leaked message reference Brian Gix
2020-05-22 23:37   ` [BlueZ,v2,3/4] " bluez.test.bot
2020-05-22 21:13 ` [PATCH BlueZ v2 4/4] mesh: Destroy PB-ADV queue when provisioning done Brian Gix
2020-05-22 23:37   ` [BlueZ,v2,4/4] " bluez.test.bot
2020-05-25 14:15 ` [PATCH BlueZ v2 0/4] mesh: Static Analysis clean-up Gix, Brian

Linux-Bluetooth Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-bluetooth/0 linux-bluetooth/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-bluetooth linux-bluetooth/ https://lore.kernel.org/linux-bluetooth \
		linux-bluetooth@vger.kernel.org
	public-inbox-index linux-bluetooth

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-bluetooth


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git