diff --git a/gtests/net/packetdrill/run_system_call.c b/gtests/net/packetdrill/run_system_call.c
index 55a3fba1157980e953b4aa75639c542c832a9fec..cd60052fdfb6d41b6048626c20e28c3c377320ac 100644
--- a/gtests/net/packetdrill/run_system_call.c
+++ b/gtests/net/packetdrill/run_system_call.c
@@ -3905,10 +3905,12 @@ static int syscall_setsockopt(struct state *state, struct syscall_spec *syscall,
 		return STATUS_ERR;
 	switch (val_expression->type) {
 	case EXPR_LINGER:
-		get_s32(val_expression->value.linger->l_onoff,
-			&linger.l_onoff, error);
-		get_s32(val_expression->value.linger->l_linger,
-			&linger.l_linger, error);
+		if (get_s32(val_expression->value.linger->l_onoff,
+		            &linger.l_onoff, error))
+			return STATUS_ERR;
+		if (get_s32(val_expression->value.linger->l_linger,
+		            &linger.l_linger, error))
+			return STATUS_ERR;
 		optval = &linger;
 		if (!optlen_provided) {
 			optlen = (socklen_t)sizeof(struct linger);