[CRIU] [PATCH] soccr: don't dereference data before null check

Andrei Vagin avagin at openvz.org
Thu Dec 8 13:48:47 PST 2016


From: Andrei Vagin <avagin at virtuozzo.com>

CID 173075 (#1 of 1): Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking data suggests that it may be null, but it has already been dereferenced on all paths leading to the check.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 soccr/soccr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/soccr/soccr.c b/soccr/soccr.c
index 6be8f7d..bc78ad2 100644
--- a/soccr/soccr.c
+++ b/soccr/soccr.c
@@ -400,15 +400,16 @@ static int set_queue_seq(struct libsoccr_sk *sk, int queue, __u32 seq)
 int libsoccr_set_sk_data_noq(struct libsoccr_sk *sk,
 		struct libsoccr_sk_data *data, unsigned data_size)
 {
-	int mstate = 1 << data->state;
 	struct tcp_repair_opt opts[4];
-	int addr_size;
+	int addr_size, mstate;
 	int onr = 0;
 	__u32 seq;
 
 	if (!data || data_size < SOCR_DATA_MIN_SIZE)
 		return -1;
 
+	mstate = 1 << data->state;
+
 	if (data->state == TCP_LISTEN)
 		return -1;
 
-- 
2.7.4



More information about the CRIU mailing list