From: Yu Watanabe Date: Sat, 26 Jun 2021 17:30:52 +0000 (+0900) Subject: sd-netlink: do not trigger assertion by calling socket_broadcast_group_unref() with... X-Git-Tag: v249-rc3~32^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eee15fff4005c3a7c7dffba8776a96c050464b1a;p=thirdparty%2Fsystemd.git sd-netlink: do not trigger assertion by calling socket_broadcast_group_unref() with an arbitrary group number 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. --- diff --git a/src/libsystemd/sd-netlink/netlink-socket.c b/src/libsystemd/sd-netlink/netlink-socket.c index a29210e1ce9..21ec00cca07 100644 --- a/src/libsystemd/sd-netlink/netlink-socket.c +++ b/src/libsystemd/sd-netlink/netlink-socket.c @@ -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--;