ofproto-dpif: Avoid segfault for ports with bundles in add_mirror_actions().
authorBen Pfaff <blp@nicira.com>
Tue, 13 Dec 2011 22:42:11 +0000 (14:42 -0800)
committerBen Pfaff <blp@nicira.com>
Tue, 13 Dec 2011 22:42:11 +0000 (14:42 -0800)
Not every port has an associated bundle, so we must not unconditionally
dereference ofport->bundle without first checking that it is nonnull.

(One example of a port without a bundle is a VLAN splinter port.)

Bug #8671.
Reported-by: Michael Mao <mmao@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto/ofproto-dpif.c

index 1b654fd9a09ef95f3cc4815da7dc012777c5b75e..e68bec355d7c9b06af011b9479b93059857bb838 100644 (file)
@@ -4993,7 +4993,9 @@ add_mirror_actions(struct action_xlate_ctx *ctx, const struct flow *orig_flow)
         }
 
         ofport = get_odp_port(ofproto, nl_attr_get_u32(a));
-        mirrors |= ofport ? ofport->bundle->dst_mirrors : 0;
+        if (ofport && ofport->bundle) {
+            mirrors |= ofport->bundle->dst_mirrors;
+        }
     }
 
     if (!mirrors) {