]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Guard printing an error by checking if VRF is not NULL
authorDonatas Abraitis <donatas@opensourcerouting.org>
Sat, 8 Jul 2023 08:26:03 +0000 (11:26 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 10 Jul 2023 19:37:35 +0000 (22:37 +0300)
Check if vrf_lookup_by_id() didn't return a NULL before dereferencing in
flor_err().

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
zebra/interface.c

index cf36594b3493b643261b37704acbbddb3d02d224..4c9f9f30926df47f9fb6d67aeb067c008d90ff80 100644 (file)
@@ -1531,10 +1531,16 @@ static void interface_vrf_change(enum dplane_op_e op, ifindex_t ifindex,
                        if (exist_id != VRF_DEFAULT) {
                                vrf = vrf_lookup_by_id(exist_id);
 
-                               flog_err(
-                                       EC_ZEBRA_VRF_MISCONFIGURED,
-                                       "VRF %s id %u table id overlaps existing vrf %s(%d), misconfiguration exiting",
-                                       name, ifindex, vrf->name, vrf->vrf_id);
+                               if (vrf)
+                                       flog_err(EC_ZEBRA_VRF_MISCONFIGURED,
+                                                "VRF %s id %u table id overlaps existing vrf %s(%d), misconfiguration exiting",
+                                                name, ifindex, vrf->name,
+                                                vrf->vrf_id);
+                               else
+                                       flog_err(EC_ZEBRA_VRF_NOT_FOUND,
+                                                "VRF %s id %u does not exist",
+                                                name, ifindex);
+
                                exit(-1);
                        }
                }