diff mbox series

station: fix crash if affinities watch gets removed

Message ID 20240910184750.126488-1-prestwoj@gmail.com (mailing list archive)
State New
Headers show
Series station: fix crash if affinities watch gets removed | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-alpine-ci-setupell success Prep - Setup ELL
prestwoj/iwd-ci-setupell success Prep - Setup ELL
prestwoj/iwd-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-alpine-ci-makedistcheck success Make Distcheck
prestwoj/iwd-alpine-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-ci-makecheck success Make Check
prestwoj/iwd-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-ci-clang success clang PASS
prestwoj/iwd-alpine-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-alpine-ci-makecheck success Make Check
prestwoj/iwd-ci-testrunner success test-runner PASS

Commit Message

James Prestwood Sept. 10, 2024, 6:47 p.m. UTC
If the affinity watch is removed by setting an empty list the
disconnect callback won't be called which was the only place
the watch ID was cleared. This resulted in the next SetProperty call
to think a watch existed, and attempt to compare the sender address
which would be NULL.

The watch ID should be cleared inside the destroy callback, not
the disconnect callback.
---
 src/station.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Denis Kenzior Sept. 11, 2024, 12:42 a.m. UTC | #1
Hi James,

On 9/10/24 1:47 PM, James Prestwood wrote:
> If the affinity watch is removed by setting an empty list the
> disconnect callback won't be called which was the only place
> the watch ID was cleared. This resulted in the next SetProperty call
> to think a watch existed, and attempt to compare the sender address
> which would be NULL.
> 
> The watch ID should be cleared inside the destroy callback, not
> the disconnect callback.
> ---
>   src/station.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 

applied, thanks.

Regards,
-Denis
diff mbox series

Patch

diff --git a/src/station.c b/src/station.c
index 56a90f5f..44f5f771 100644
--- a/src/station.c
+++ b/src/station.c
@@ -4598,7 +4598,6 @@  static void station_affinity_disconnected_cb(struct l_dbus *dbus,
 	struct station *station = user_data;
 
 	l_dbus_remove_watch(dbus_get_bus(), station->affinity_watch);
-	station->affinity_watch = 0;
 
 	l_debug("client that set affinity has disconnected");
 
@@ -4611,6 +4610,8 @@  static void station_affinity_watch_destroy(void *user_data)
 	struct station *station = user_data;
 	bool empty = l_queue_length(station->affinities) == 0;
 
+	station->affinity_watch = 0;
+
 	l_free(station->affinity_client);
 	station->affinity_client = NULL;