Skip to contentSkip to conversation

gdbus: fix double free

PATCH New Colin Wee 3 participants 5 messages Apr 5, 2025 – Apr 7, 2025

lore
Share & tools
lore

Colin Wee

author
#0 lore raw

PATCH 1/1 gdbus: fix double free

Hey Connman Maintainers,

I'd like to submit a patch to avoid potential memory corruption in connman. I've attached it for review, please let me know what you think!

-Colin

author
#1 lore raw

PATCH 1/1 gdbus: fix double free

These are freed later in filter_data_free.

---
 gdbus/watch.c | 1 -
 1 file changed, 1 deletion(-)
gdbus/watch.c +0 -1
index 8fa76cda..5cb2167e 100644
@@ -332,7 +332,6 @@ static void filter_data_call_and_free(struct filter_data *data)
 			cb->disc_func(data->connection, cb->user_data);
 		if (cb->destroy_func)
 			cb->destroy_func(cb->user_data);
-		g_free(cb);
 	}
 
 	filter_data_free(data);
Signature · 1 line
2.49.0
#2 lore raw

Hi Colin,

+1 for this, it was also found by Clang analyzer, I forgot to push my finding on this here https://github.com/sailfishos/connman/commit/6aa2c2910edc2186233da64726d4afa0c17aa5b3

Cheers,
Jussi

Quoted 19 lines · Colin Wee

These are freed later in filter_data_free.

---
  gdbus/watch.c | 1 -
  1 file changed, 1 deletion(-)
gdbus/watch.c +0 -1
index 8fa76cda..5cb2167e 100644
@@ -332,7 +332,6 @@ static void filter_data_call_and_free(struct filter_data *data)
  			cb->disc_func(data->connection, cb->user_data);
  		if (cb->destroy_func)
  			cb->destroy_func(cb->user_data);
-		g_free(cb);
  	}
 
  	filter_data_free(data);
author
#3 lore raw

Nice, Jussi! Glad we arrived at the same fix :)

-Colin

Quoted 28 lines · Jussi Laakkonen

Hi Colin,

+1 for this, it was also found by Clang analyzer, I forgot to push my
finding on this here https://github.com/sailfishos/connman/commit/6aa2c2910edc2186233da64726d4afa0c17aa5b3

Cheers,
Jussi

Quoted 18 lines · Colin Wee

These are freed later in filter_data_free.

---
  gdbus/watch.c | 1 -
  1 file changed, 1 deletion(-)
gdbus/watch.c +0 -1
index 8fa76cda..5cb2167e 100644
@@ -332,7 +332,6 @@ static void filter_data_call_and_free(struct filter_data *data)
                    cb->disc_func(data->connection, cb->user_data);
            if (cb->destroy_func)
                    cb->destroy_func(cb->user_data);
-           g_free(cb);
    }
    filter_data_free(data);
#4 lore raw
In reply to Colin Wee
This patch was applied to connman.git (master) by Denis Kenzior <[email protected]>:

Hello:

This patch was applied to connman.git (master)
by Denis Kenzior <[email protected]>:

Quoted 6 lines · On Sat, 5 Apr 2025 02:09:55 +0000 you wrote:

These are freed later in filter_data_free.

---
 gdbus/watch.c | 1 -
 1 file changed, 1 deletion(-)

Here is the summary with links:
- gdbus: fix double free

    https://git.kernel.org/pub/scm/network/connman/connman.git/?id=96dbccb35e00

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html