public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] station: fix crash if affinities watch gets removed
@ 2024-09-10 18:47 James Prestwood
  2024-09-11  0:42 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: James Prestwood @ 2024-09-10 18:47 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

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(-)

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;
 
-- 
2.34.1


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

* Re: [PATCH] station: fix crash if affinities watch gets removed
  2024-09-10 18:47 [PATCH] station: fix crash if affinities watch gets removed James Prestwood
@ 2024-09-11  0:42 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2024-09-11  0:42 UTC (permalink / raw)
  To: James Prestwood, iwd

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


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

end of thread, other threads:[~2024-09-11  0:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-10 18:47 [PATCH] station: fix crash if affinities watch gets removed James Prestwood
2024-09-11  0:42 ` Denis Kenzior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox