From: Jouni Malinen Date: Sun, 27 Dec 2009 19:20:25 +0000 (+0200) Subject: test: Add WPA_TRACE reference check for driver ctx X-Git-Tag: hostap_0_7_1~175 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f78feb6a7268584a88b2dfd384e31e320b887e10;p=thirdparty%2Fhostap.git test: Add WPA_TRACE reference check for driver ctx This will catch too early freeing of the context pointer before the driver wrapper has been deinitialized. --- diff --git a/src/drivers/driver_test.c b/src/drivers/driver_test.c index 196112f81..3bfa6d485 100644 --- a/src/drivers/driver_test.c +++ b/src/drivers/driver_test.c @@ -18,7 +18,7 @@ #include #endif /* CONFIG_NATIVE_WINDOWS */ -#include "includes.h" +#include "utils/includes.h" #ifndef CONFIG_NATIVE_WINDOWS #include @@ -27,12 +27,13 @@ #define DRIVER_TEST_UNIX #endif /* CONFIG_NATIVE_WINDOWS */ -#include "common.h" -#include "driver.h" -#include "l2_packet/l2_packet.h" -#include "eloop.h" -#include "crypto/sha1.h" +#include "utils/common.h" +#include "utils/eloop.h" +#include "utils/trace.h" #include "common/ieee802_11_defs.h" +#include "crypto/sha1.h" +#include "l2_packet/l2_packet.h" +#include "driver.h" struct test_client_socket { @@ -66,6 +67,7 @@ struct wpa_driver_test_global { struct wpa_driver_test_data { struct wpa_driver_test_global *global; void *ctx; + WPA_TRACE_REF(ctx); char ifname[IFNAMSIZ + 1]; u8 own_addr[ETH_ALEN]; int test_socket; @@ -1128,6 +1130,7 @@ static struct wpa_driver_test_data * test_alloc_data(void *ctx, } drv->ctx = ctx; + wpa_trace_add_ref(drv, ctx, ctx); os_strlcpy(drv->ifname, ifname, IFNAMSIZ); /* Generate a MAC address to help testing with multiple STAs */ @@ -1972,6 +1975,7 @@ static void wpa_driver_test_deinit(void *priv) for (i = 0; i < MAX_SCAN_RESULTS; i++) os_free(drv->scanres[i]); os_free(drv->probe_req_ie); + wpa_trace_remove_ref(drv, ctx, drv->ctx); os_free(drv); }