vhost: fix error path when setting memory tables
authorMaxime Coquelin <maxime.coquelin@redhat.com>
Thu, 12 Nov 2020 17:10:27 +0000 (18:10 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 13 Nov 2020 18:43:26 +0000 (19:43 +0100)
commit726a14eb83a594011aba5e09159b47f12bc1bad0
tree7e6ac4f3ecb111d78e711b13640f78590cd01b69
parent6e9a9d2a02ae790772fa11768793223ba546fce6
vhost: fix error path when setting memory tables

If an error is encountered before the memory regions are
parsed, the file descriptors for these shared buffers are
leaked.

This patch fixes this by closing the message file descriptors
on error, taking care of avoiding double closing of the file
descriptors. guest_pages is also freed, even though it was not
leaked as its pointer was not overridden on subsequent function
calls.

Fixes: 8f972312b8f4 ("vhost: support vhost-user")
Cc: stable@dpdk.org
Reported-by: Xuan Ding <xuan.ding@intel.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
Reviewed-by: Xueming Li <xuemingl@nvidia.com>
lib/librte_vhost/vhost_user.c