diff --git a/gtests/net/packetdrill/packet_socket_pcap.c b/gtests/net/packetdrill/packet_socket_pcap.c
index c349c700d649d0d8c926de5292ddf05dee4698c6..57eb63df94aea03a26a02fd912a74c6e074d262e 100644
--- a/gtests/net/packetdrill/packet_socket_pcap.c
+++ b/gtests/net/packetdrill/packet_socket_pcap.c
@@ -126,7 +126,7 @@ void packet_socket_set_filter(struct packet_socket *psock,
 			      const struct ether_addr *client_ether_addr,
 			      const struct ip_address *client_live_ip)
 {
-	const u8 *client_ether = client_ether_addr->ether_addr_octet;
+	const u8 *client_ether;
 	struct bpf_program bpf_code;
 	char *filter_str = NULL;
 	char client_live_ip_string[ADDR_STR_LEN];
@@ -134,6 +134,7 @@ void packet_socket_set_filter(struct packet_socket *psock,
 	ip_to_string(client_live_ip, client_live_ip_string);
 
 	if (client_ether_addr != NULL)
+		client_ether = client_ether_addr->ether_addr_octet;
 		asprintf(&filter_str,
 			 "ether src %02x:%02x:%02x:%02x:%02x:%02x and %s src %s",
 			 client_ether[0],