bridge: Avoid reading uninitialized data in bridge_pick_local_hw_addr().
authorBen Pfaff <blp@nicira.com>
Fri, 9 Sep 2011 17:12:32 +0000 (10:12 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 9 Sep 2011 23:40:16 +0000 (16:40 -0700)
Commit 3a48ace3 "bridge: Make bridge_pick_local_hw_addr() easier to reason"
didn't initialize 'ea' before trying to compare against it.  We need to
check that an address has been found.

Found by valgrind.

vswitchd/bridge.c

index abea4f348175deafcabf90b59ebe4eebcb83696f..ba5fbc6fe01e39b3d3a71ba46477cf65e4180f3a 100644 (file)
@@ -1080,7 +1080,7 @@ bridge_pick_local_hw_addr(struct bridge *br, uint8_t ea[ETH_ADDR_LEN],
             !eth_addr_is_local(iface_ea) &&
             !eth_addr_is_reserved(iface_ea) &&
             !eth_addr_is_zero(iface_ea) &&
-            eth_addr_compare_3way(iface_ea, ea) < 0)
+            (!found_addr || eth_addr_compare_3way(iface_ea, ea) < 0))
         {
             memcpy(ea, iface_ea, ETH_ADDR_LEN);
             *hw_addr_iface = iface;