diff mbox series

[2/7] p2p: Simplify handshake_state cleanup

Message ID 20231201040020.161143-2-denkenz@gmail.com (mailing list archive)
State New
Headers show
Series [1/7] handshake: Add cleanup function for handshake_state | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint success GitLint

Commit Message

Denis Kenzior Dec. 1, 2023, 4 a.m. UTC
---
 src/p2p.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/src/p2p.c b/src/p2p.c
index 5d96e6825e1a..c823b2b134dd 100644
--- a/src/p2p.c
+++ b/src/p2p.c
@@ -1496,7 +1496,7 @@  static void p2p_handshake_event(struct handshake_state *hs,
 static void p2p_try_connect_group(struct p2p_device *dev)
 {
 	struct scan_bss *bss = dev->conn_wsc_bss;
-	struct handshake_state *hs = NULL;
+	_auto_(handshake_state_free) struct handshake_state *hs = NULL;
 	struct iovec ie_iov[16];
 	int ie_num = 0;
 	int r;
@@ -1562,6 +1562,7 @@  static void p2p_try_connect_group(struct p2p_device *dev)
 		goto error;
 	}
 
+	l_steal_ptr(hs);
 	dev->conn_retry_count++;
 
 done:
@@ -1570,9 +1571,6 @@  done:
 
 error:
 not_supported:
-	if (hs)
-		handshake_state_free(hs);
-
 	p2p_connect_failed(dev);
 	goto done;
 }