Skip to contentSkip to conversation

: libblktapctl, fix use-after-free bug

PATCH New Gianni Tedesco 1 participant 1 message Aug 3, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : libblktapctl, fix use-after-free bug

This has not caused crashes because generally use after free is OK provided nothing else is going on. However the patch makes things correct. It also allows us to use heap poisoning feature of valgrind on tools linking to libblktapctl.

tools/blktap2/control/tap-ctl-list.c +2 -2
diff -r 5c5a6081f258 tools/blktap2/control/tap-ctl-list.c
@@ -385,9 +385,9 @@ _tap_ctl_free_tapdisks(struct tapdisk *t
 	struct tapdisk *tap;
 
 	for (tap = tapv; tap < &tapv[n_taps]; ++tap) {
-		struct tapdisk_list *tl;
+		struct tapdisk_list *tl, *next;
 
-		list_for_each_entry(tl, &tap->list, entry) {
+		list_for_each_entry_safe(tl, next, &tap->list, entry) {
 			free(tl->params);
 			free(tl);
 		}