Skip to content

Commit

Permalink
vhost-vdpa: set v->config_ctx to NULL if eventfd_ctx_fdget() fails
Browse files Browse the repository at this point in the history
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: 776f395 ("vhost_vdpa: Support config interrupt in vdpa")
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Stefano Garzarella <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Michael S. Tsirkin <[email protected]>
Acked-by: Jason Wang <[email protected]>
  • Loading branch information
stefano-garzarella authored and mstsirkin committed Mar 14, 2021
1 parent f6bbf00 commit 0bde59c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/vhost/vdpa.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,12 @@ static long vhost_vdpa_set_config_call(struct vhost_vdpa *v, u32 __user *argp)
if (!IS_ERR_OR_NULL(ctx))
eventfd_ctx_put(ctx);

if (IS_ERR(v->config_ctx))
return PTR_ERR(v->config_ctx);
if (IS_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);

Expand Down

0 comments on commit 0bde59c

Please sign in to comment.