ovs-lldp: Avoid use-after-free in aa_mapping_unregister().
authorBen Pfaff <blp@nicira.com>
Thu, 16 Apr 2015 21:46:27 +0000 (14:46 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 17 Apr 2015 16:23:04 +0000 (09:23 -0700)
Found by LLVM scan-build.

Reported-by: Kevin Lo <kevlo@FreeBSD.org>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Dennis Flynn <drflynn@avaya.com>
lib/ovs-lldp.c

index 61534a4..db213b4 100644 (file)
@@ -619,7 +619,6 @@ aa_mapping_unregister(void *aux)
             }
 
             hmap_remove(&lldp->mappings_by_aux, &m->hmap_node_aux);
-            free(m);
 
             /* Remove from all the lldp instances */
             LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware) {
@@ -629,6 +628,7 @@ aa_mapping_unregister(void *aux)
 
                 aa_mapping_unregister_mapping(lldp, hw, m);
             }
+            free(m);
 
             /* Remove from the all_mappings */
             HMAP_FOR_EACH (m, hmap_node_isid, all_mappings) {