ell.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] netlink: Allow command handler to use l_netlink_cancel
@ 2021-03-02 11:14 Andrew Zaborowski
  2021-03-02 15:10 ` Denis Kenzior
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Zaborowski @ 2021-03-02 11:14 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 1002 bytes --]

---
 ell/netlink.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/ell/netlink.c b/ell/netlink.c
index 33d0e5b..4664762 100644
--- a/ell/netlink.c
+++ b/ell/netlink.c
@@ -162,12 +162,15 @@ static void process_message(struct l_netlink *netlink, struct nlmsghdr *nlmsg)
 {
 	const void *data = nlmsg;
 	struct command *command;
+	uint32_t id;
 
 	command = l_hashmap_remove(netlink->command_pending,
 					L_UINT_TO_PTR(nlmsg->nlmsg_seq));
 	if (!command)
 		return;
 
+	id = command->id;
+
 	if (!command->handler)
 		goto done;
 
@@ -189,9 +192,8 @@ static void process_message(struct l_netlink *netlink, struct nlmsghdr *nlmsg)
 	}
 
 done:
-	l_hashmap_remove(netlink->command_lookup, L_UINT_TO_PTR(command->id));
-
-	destroy_command(command);
+	if (l_hashmap_remove(netlink->command_lookup, L_UINT_TO_PTR(id)))
+		destroy_command(command);
 }
 
 static void process_multi(struct l_netlink *netlink, struct nlmsghdr *nlmsg)
-- 
2.27.0

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

end of thread, other threads:[~2021-03-03  0:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-02 11:14 [PATCH] netlink: Allow command handler to use l_netlink_cancel Andrew Zaborowski
2021-03-02 15:10 ` Denis Kenzior
2021-03-02 15:34   ` Andrew Zaborowski
2021-03-02 16:35     ` Denis Kenzior
2021-03-02 21:30       ` Andrew Zaborowski
2021-03-02 23:29         ` Denis Kenzior
2021-03-03  0:02           ` Andrew Zaborowski
2021-03-03  0:18             ` Denis Kenzior
2021-03-02 21:36     ` Andrew Zaborowski
2021-03-03  0:03       ` Denis Kenzior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).