[ovs-dev] [PATCH 1/5] ofproto: Avoid wild write removing OFPP_LOCAL port in dealloc_ofp_port().

Ben Pfaff blp at nicira.com
Thu Jan 24 19:47:56 UTC 2013


Found by valgrind.

Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 ofproto/ofproto.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 9bae971..b6cd082 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -1644,7 +1644,9 @@ alloc_ofp_port(struct ofproto *ofproto, const char *netdev_name)
 static void
 dealloc_ofp_port(const struct ofproto *ofproto, uint16_t ofp_port)
 {
-    bitmap_set0(ofproto->ofp_port_ids, ofp_port);
+    if (ofp_port < ofproto->max_ports) {
+        bitmap_set0(ofproto->ofp_port_ids, ofp_port);
+    }
 }
 
 /* Opens and returns a netdev for 'ofproto_port' in 'ofproto', or a null
-- 
1.7.2.5




More information about the dev mailing list