Skip to contentSkip to conversation

Fix invalid read of memory in avdtp module

PATCH Applied Rafal Michalski 2 participants 2 messages May 27, 2011 – May 29, 2011 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix invalid read of memory in avdtp module

Fixed incorrect update of server->sessions GSlist in avdtp_exit. Previosly it was leading to invalid read of memory (l = l->next) (and possible memory leaks) since after invoking avdtp_unref in connection_lost, l pointer was not valid anymore (previously assignment l = l->next was used after invoking connection_lost in for loop).

---
 audio/avdtp.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
audio/avdtp.c +7 -1
index e6407bb..3b2a9ae 100644
@@ -3857,9 +3857,15 @@ void avdtp_exit(const bdaddr_t *src)
 	if (!server)
 		return;
 
-	for (l = server->sessions; l; l = l->next) {
+	l = server->sessions;
+	while (l) {
 		struct avdtp *session = l->data;
 
+		l = l->next;
+		/* value of l pointer should be updated before invoking
+		 * connection_lost since it internally uses avdtp_unref
+		 * which operates on server->session list as well
+		 */
 		connection_lost(session, -ECONNABORTED);
 	}
 
Signature · 1 line
1.6.3.3
#1 lore raw

Hi Rafal,

Quoted 8 lines · Rafal Michalski

Fixed incorrect update of server->sessions GSlist in avdtp_exit. Previosly it was leading to invalid read of memory (l = l->next) (and possible memory leaks) since after invoking avdtp_unref in connection_lost, l pointer was not valid anymore (previously assignment l = l->next was used after invoking connection_lost in for loop).

---
 audio/avdtp.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

Applied. Thanks.

Johan