public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH 1/7] handshake: Add cleanup function for handshake_state
@ 2023-12-01  4:00 Denis Kenzior
  2023-12-01  4:00 ` [PATCH 2/7] p2p: Simplify handshake_state cleanup Denis Kenzior
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Denis Kenzior @ 2023-12-01  4:00 UTC (permalink / raw)
  To: iwd; +Cc: Denis Kenzior

To allow _auto_(handshake_state_free) variables to be used.
---
 src/handshake.c | 7 ++++++-
 src/handshake.h | 3 +++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/handshake.c b/src/handshake.c
index 6b93774ab137..1c5ed2c9bc12 100644
--- a/src/handshake.c
+++ b/src/handshake.c
@@ -105,7 +105,12 @@ void __handshake_set_install_ext_tk_func(handshake_install_ext_tk_func_t func)
 
 void handshake_state_free(struct handshake_state *s)
 {
-	__typeof__(s->free) destroy = s->free;
+	__typeof__(s->free) destroy;
+
+	if (!s)
+		return;
+
+	destroy = s->free;
 
 	if (s->in_event) {
 		s->in_event = false;
diff --git a/src/handshake.h b/src/handshake.h
index 7200c3617b8e..815eb44ff6ba 100644
--- a/src/handshake.h
+++ b/src/handshake.h
@@ -24,6 +24,7 @@
 #include <stdbool.h>
 #include <asm/byteorder.h>
 #include <linux/types.h>
+#include <ell/cleanup.h>
 
 struct handshake_state;
 enum crypto_cipher;
@@ -298,3 +299,5 @@ const uint8_t *handshake_util_find_pmkid_kde(const uint8_t *data,
 					size_t data_len);
 void handshake_util_build_gtk_kde(enum crypto_cipher cipher, const uint8_t *key,
 					unsigned int key_index, uint8_t *to);
+
+DEFINE_CLEANUP_FUNC(handshake_state_free);
-- 
2.43.0


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

end of thread, other threads:[~2023-12-01 16:47 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-01  4:00 [PATCH 1/7] handshake: Add cleanup function for handshake_state Denis Kenzior
2023-12-01  4:00 ` [PATCH 2/7] p2p: Simplify handshake_state cleanup Denis Kenzior
2023-12-01  4:00 ` [PATCH 3/7] p2p: Simplify cleanup of ies Denis Kenzior
2023-12-01  4:00 ` [PATCH 4/7] netdev: iov_ie_append: Support iovecs with multiple IEs Denis Kenzior
2023-12-01  4:00 ` [PATCH 5/7] p2p: Use handshake to pass vendor ies Denis Kenzior
2023-12-01  4:00 ` [PATCH 6/7] wsc: " Denis Kenzior
2023-12-01  4:00 ` [PATCH 7/7] netdev: Remove vendor_ies from netdev_connect signature Denis Kenzior
2023-12-01 12:42 ` [PATCH 1/7] handshake: Add cleanup function for handshake_state James Prestwood
2023-12-01 15:08   ` Denis Kenzior
2023-12-01 15:22     ` James Prestwood
2023-12-01 15:32       ` James Prestwood
2023-12-01 16:06         ` James Prestwood
2023-12-01 16:32           ` Denis Kenzior
2023-12-01 16:47             ` James Prestwood
2023-12-01 16:30 ` Denis Kenzior

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