]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-netlink: do not trigger assertion by calling socket_broadcast_group_unref() with...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 26 Jun 2021 17:30:52 +0000 (02:30 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 26 Jun 2021 17:47:34 +0000 (02:47 +0900)
socket_broadcast_group_unref() is only called in netlink_slot_disconnect(),
so the assertion should not be triggered as the match slot was
successfully created.

But, we usually design `_ref/unref()` functions as they can be called
for any inputs. So, let's also follow the design rule here.

src/libsystemd/sd-netlink/netlink-socket.c

index a29210e1ce9a5ba5fd15d6ecc8b834a890ddc2a2..21ec00cca073e6048d2edde0283ac841efff5359 100644 (file)
@@ -160,8 +160,8 @@ int socket_broadcast_group_unref(sd_netlink *nl, unsigned group) {
         assert(nl);
 
         n_ref = broadcast_group_get_ref(nl, group);
-
-        assert(n_ref > 0);
+        if (n_ref == 0)
+                return 0;
 
         n_ref--;