ofproto-dpif: Fix segfault in mirror_update_dups().
authorJustin Pettit <jpettit@nicira.com>
Thu, 17 Nov 2011 22:08:09 +0000 (14:08 -0800)
committerJustin Pettit <jpettit@nicira.com>
Thu, 17 Nov 2011 22:31:07 +0000 (14:31 -0800)
Fixes crash introduced in 9ba15e (ofproto-dpif: Improve RSPAN
translation performance from O(n**2) to O(n).)  The code always
dereferenced the members of the "mirrors" array in ofproto even if they
were null.

ofproto/ofproto-dpif.c

index 86723e1..3e92493 100644 (file)
@@ -1682,7 +1682,7 @@ mirror_update_dups(struct ofproto_dpif *ofproto)
         for (j = i + 1; j < MAX_MIRRORS; j++) {
             struct ofmirror *m2 = ofproto->mirrors[j];
 
-            if (m1->out == m2->out && m1->out_vlan == m2->out_vlan) {
+            if (m2 && m1->out == m2->out && m1->out_vlan == m2->out_vlan) {
                 m1->dup_mirrors |= MIRROR_MASK_C(1) << j;
                 m2->dup_mirrors |= m1->dup_mirrors;
             }