ofproto-dpif: Fix null pointer dereference in get_ofp_port().
authorBen Pfaff <blp@nicira.com>
Fri, 13 May 2011 23:50:20 +0000 (16:50 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 13 May 2011 23:50:20 +0000 (16:50 -0700)
ofproto/ofproto-dpif.c

index 93acd429bbdadd6663b0a1e8fb46ad31892e6fd0..b7194930d0a0e17bbf98605706f7a1b363dec053 100644 (file)
@@ -1353,7 +1353,8 @@ is_mirror_output_bundle(struct ofproto *ofproto_, void *aux)
 static struct ofport_dpif *
 get_ofp_port(struct ofproto_dpif *ofproto, uint16_t ofp_port)
 {
-    return ofport_dpif_cast(ofproto_get_port(&ofproto->up, ofp_port));
+    struct ofport *ofport = ofproto_get_port(&ofproto->up, ofp_port);
+    return ofport ? ofport_dpif_cast(ofport) : NULL;
 }
 
 static struct ofport_dpif *