[dpdk-stable] [PATCH 16.11] vhost-user: fix false negative in handling user messages

Luca Boccassi bluca at debian.org
Wed Nov 28 17:20:54 CET 2018


vhost_user_msg_handler checks an accumulated return code before
returning, and prints an error and returns -1 if it's non-zero.
But some of the possible user messages cannot fail and thus do not
set the variable, which might retain a previously set and unrelated
value, causing unnecessary failures and error messages.

Reset the return code before use.

Fixes: 0ce9e73d1e8d ("vhost-user: drop connection on message handling failures")

Signed-off-by: Luca Boccassi <bluca at debian.org>
---
Found this issue when testing with the Vyatta stuff, "ret" is set at
the beginning of the function and never reset when the message is for example
VHOST_USER_GET_FEATURES so there's a flurry of errors.

 lib/librte_vhost/vhost_user.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 00872c868..618d413fe 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -1087,6 +1087,7 @@ vhost_user_msg_handler(int vid, int fd)
 
 	}
 
+	ret = 0;
 	switch (msg.request) {
 	case VHOST_USER_GET_FEATURES:
 		msg.payload.u64 = vhost_user_get_features();
-- 
2.19.2



More information about the stable mailing list