vhost/crypto: fix checks while moving descriptors
authorFan Zhang <roy.fan.zhang@intel.com>
Fri, 27 Apr 2018 14:06:08 +0000 (15:06 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 27 Apr 2018 17:49:20 +0000 (19:49 +0200)
This patch fix final condition check while moving virtqueue
descriptors.

Fixes: 3bb595ecd682 ("vhost/crypto: add request handler")

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
lib/librte_vhost/vhost_crypto.c

index 620a1df..7396ddd 100644 (file)
@@ -506,7 +506,7 @@ move_desc(struct vring_desc *head, struct vring_desc **cur_desc,
                left -= desc->len;
        }
 
-       if (unlikely(left < 0)) {
+       if (unlikely(left > 0)) {
                VC_LOG_ERR("Incorrect virtio descriptor");
                return -1;
        }
@@ -553,7 +553,7 @@ copy_data(void *dst_data, struct vring_desc *head, struct rte_vhost_memory *mem,
                left -= to_copy;
        }
 
-       if (unlikely(left < 0)) {
+       if (unlikely(left > 0)) {
                VC_LOG_ERR("Incorrect virtio descriptor");
                return -1;
        }