On 20/04/2020 11:32, Cindy Lu wrote:
> This is a small function  that can get the peer from given NetClientState and 
> queue_index
> 
> Signed-off-by: Cindy Lu <l...@redhat.com>
> ---
>  hw/net/vhost_net.c | 16 ++++++++++------
>  include/net/net.h  |  1 +
>  net/net.c          |  6 ++++++
>  3 files changed, 17 insertions(+), 6 deletions(-)
> 
...
> diff --git a/net/net.c b/net/net.c
> index 84aa6d8d00..ac5080dda1 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -324,6 +324,12 @@ void *qemu_get_nic_opaque(NetClientState *nc)
>  
>      return nic->opaque;
>  }
> +NetClientState *qemu_get_peer(NetClientState *nc, int queue_index)
> +{
> +    NetClientState *ncs  =  nc + queue_index;
> +    assert(ncs != NULL);

This will not assert if nc is NULL and queue_index != 0.

You should check value of nc and then calculate ncs.

Thanks,
Laurent


Reply via email to