提交 1e969a8d 编写于 作者: S Stefano Garzarella 提交者: Zheng Zengkai

vhost-vdpa: set v->config_ctx to NULL if eventfd_ctx_fdget() fails

stable inclusion
from stable-5.10.26
commit 4daa70a80c68c76df87d70565cf62f716e240e0f
bugzilla: 51363

--------------------------------

commit 0bde59c1 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: 776f3950 ("vhost_vdpa: Support config interrupt in vdpa")
Cc: lingshan.zhu@intel.com
Cc: stable@vger.kernel.org
Signed-off-by: NStefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20210311135257.109460-3-sgarzare@redhat.comSigned-off-by: NMichael S. Tsirkin <mst@redhat.com>
Acked-by: NJason Wang <jasowang@redhat.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: N  Weilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 c02e82bc
...@@ -335,8 +335,12 @@ static long vhost_vdpa_set_config_call(struct vhost_vdpa *v, u32 __user *argp) ...@@ -335,8 +335,12 @@ static long vhost_vdpa_set_config_call(struct vhost_vdpa *v, u32 __user *argp)
if (!IS_ERR_OR_NULL(ctx)) if (!IS_ERR_OR_NULL(ctx))
eventfd_ctx_put(ctx); eventfd_ctx_put(ctx);
if (IS_ERR(v->config_ctx)) if (IS_ERR(v->config_ctx)) {
return PTR_ERR(v->config_ctx); long ret = PTR_ERR(v->config_ctx);
v->config_ctx = NULL;
return ret;
}
v->vdpa->config->set_config_cb(v->vdpa, &cb); v->vdpa->config->set_config_cb(v->vdpa, &cb);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册