vhost: fix use after free
authorYuanhan Liu <yuanhan.liu@linux.intel.com>
Tue, 18 Oct 2016 14:38:06 +0000 (22:38 +0800)
committerYuanhan Liu <yuanhan.liu@linux.intel.com>
Wed, 26 Oct 2016 11:39:09 +0000 (13:39 +0200)
Fix the coverity USE_AFTER_FREE issue.

Coverity issue: 137884
Fixes: a277c7159876 ("vhost: refactor code structure")

Reported-by: John McNamara <john.mcnamara@intel.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
lib/librte_vhost/socket.c

index 967cb65..aaa9c27 100644 (file)
@@ -250,8 +250,8 @@ vhost_user_read_cb(int connfd, void *dat, int *remove)
                vsocket->connfd = -1;
                close(connfd);
                *remove = 1;
-               free(conn);
                vhost_destroy_device(conn->vid);
+               free(conn);
 
                if (vsocket->reconnect)
                        vhost_user_create_client(vsocket);