]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: do not trigger assertion when link_get_by_index() called with an invalid...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 11 Dec 2023 16:27:09 +0000 (01:27 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 14 Dec 2023 09:57:43 +0000 (18:57 +0900)
Should not change any behavior. Preparation for later commit.

src/network/networkd-link.c

index a063696c82b12a7d073edf4c0951efb420f70f5f..0162e2acb0308d43b36d4b7cb5d4effe0af54fb0 100644 (file)
@@ -252,7 +252,9 @@ int link_get_by_index(Manager *m, int ifindex, Link **ret) {
         Link *link;
 
         assert(m);
-        assert(ifindex > 0);
+
+        if (ifindex <= 0)
+                return -EINVAL;
 
         link = hashmap_get(m->links_by_index, INT_TO_PTR(ifindex));
         if (!link)