vhost-vdpa: set v->config_ctx to NULL if eventfd_ctx_fdget() fails
authorStefano Garzarella <sgarzare@redhat.com>
Thu, 11 Mar 2021 13:52:57 +0000 (14:52 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Mar 2021 08:04:06 +0000 (09:04 +0100)
commit4daa70a80c68c76df87d70565cf62f716e240e0f
treef68cc34b2398761d0ed5d21485763c5fd8f3fb88
parent49ca3100fbaf864853c922c8f7a8fe7090a83860
vhost-vdpa: set v->config_ctx to NULL if eventfd_ctx_fdget() fails

commit 0bde59c1723a29e294765c96dbe5c7fb639c2f96 upstream.

In vhost_vdpa_set_config_call() if eventfd_ctx_fdget() fails the
'v->config_ctx' contains an error instead of a valid pointer.

Since we consider 'v->config_ctx' valid if it is not NULL, we should
set it to NULL in this case to avoid to use an invalid pointer in
other functions such as vhost_vdpa_config_put().

Fixes: 776f395004d8 ("vhost_vdpa: Support config interrupt in vdpa")
Cc: lingshan.zhu@intel.com
Cc: stable@vger.kernel.org
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20210311135257.109460-3-sgarzare@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/vhost/vdpa.c