Linux-Bluetooth Archive on lore.kernel.org
 help / color / Atom feed
From: Inga Stotland <inga.stotland@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com>
Subject: [PATCH BlueZ 09/10] mesh: Fix memory leak in Create, Import & Attach methods
Date: Thu, 21 May 2020 17:35:00 -0700
Message-ID: <20200522003501.106165-10-inga.stotland@intel.com> (raw)
In-Reply-To: <20200522003501.106165-1-inga.stotland@intel.com>

This ensures that every time l_dbus_message_ref() is used to preserve
a message for a pending method reply, there is a matching call to
l_dbus_message_unref().
---
 mesh/mesh.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mesh/mesh.c b/mesh/mesh.c
index c68436caa..6f8974745 100644
--- a/mesh/mesh.c
+++ b/mesh/mesh.c
@@ -309,6 +309,7 @@ static void pending_request_exit(void *data)
 
 	reply = dbus_error(msg, MESH_ERROR_FAILED, "Failed. Exiting");
 	l_dbus_send(dbus_get_bus(), reply);
+	l_dbus_message_unref(msg);
 }
 
 static void free_pending_join_call(bool failed)
@@ -628,6 +629,7 @@ static void attach_ready_cb(void *user_data, int status, struct mesh_node *node)
 		reply = dbus_error(pending_msg, status, "Attach failed");
 
 	l_dbus_send(dbus_get_bus(), reply);
+	l_dbus_message_unref(pending_msg);
 }
 
 static struct l_dbus_message *attach_call(struct l_dbus *dbus,
@@ -700,6 +702,7 @@ static void create_node_ready_cb(void *user_data, int status,
 	if (status != MESH_ERROR_NONE) {
 		reply = dbus_error(pending_msg, status, NULL);
 		l_dbus_send(dbus_get_bus(), reply);
+		l_dbus_message_unref(pending_msg);
 		return;
 	}
 
@@ -719,6 +722,7 @@ static void create_node_ready_cb(void *user_data, int status,
 	l_dbus_message_set_arguments(msg, "t", l_get_be64(token));
 	dbus_send_with_timeout(dbus, msg, create_join_complete_reply_cb,
 						node, DEFAULT_DBUS_TIMEOUT);
+	l_dbus_message_unref(pending_msg);
 }
 
 static struct l_dbus_message *create_network_call(struct l_dbus *dbus,
-- 
2.26.2


  parent reply index

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-22  0:34 [PATCH BlueZ 00/10] Mesh code clean up Inga Stotland
2020-05-22  0:34 ` [PATCH BlueZ 01/10] mesh: Remove unused structure member Inga Stotland
2020-05-22  0:34 ` [PATCH BlueZ 02/10] mesh: Free allocated agent in mesh_remove_agent() Inga Stotland
2020-05-22  0:34 ` [PATCH BlueZ 03/10] mesh: Remove agent when freeing node's dynamic resources Inga Stotland
2020-05-22  0:34 ` [PATCH BlueZ 04/10] mesh: Add finalization of a newly created node Inga Stotland
2020-05-22  0:34 ` [PATCH BlueZ 05/10] mesh: Remove unused function prototypes from node.h Inga Stotland
2020-05-22  1:12   ` [BlueZ,05/10] " bluez.test.bot
2020-05-22  0:34 ` [PATCH BlueZ 06/10] mesh: Create a queue of pending requests in mesh_init() Inga Stotland
2020-05-22  0:34 ` [PATCH BlueZ 07/10] mesh: Clean up Import() method call Inga Stotland
2020-05-22  0:34 ` [PATCH BlueZ 08/10] mesh: Clean up Attach() " Inga Stotland
2020-05-22  0:35 ` Inga Stotland [this message]
2020-05-22  0:35 ` [PATCH BlueZ 10/10] mesh: Clean up Join() method Inga Stotland
2020-05-22 20:54 ` [PATCH BlueZ 00/10] Mesh code clean up Gix, Brian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200522003501.106165-10-inga.stotland@intel.com \
    --to=inga.stotland@intel.com \
    --cc=brian.gix@intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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