Skip to content

Commit

Permalink
IB/uverbs: Release event file reference on ib_uverbs_create_cq() error
Browse files Browse the repository at this point in the history
ib_uverbs_create_cq() should release the completion channel event file
if an error occurs after it looks it up.  Also, if userspace asks for
a completion channel and we don't find it, an error should be returned
instead of silently creating a CQ without a completion channel.

Signed-off-by: Jack Morgenstein <jackm@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
  • Loading branch information
Jack Morgenstein authored and Roland Dreier committed Jan 7, 2006
1 parent ea5d4a6 commit ac4e7b3
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions drivers/infiniband/core/uverbs_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,13 +594,18 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file,
if (cmd.comp_vector >= file->device->num_comp_vectors)
return -EINVAL;

if (cmd.comp_channel >= 0)
ev_file = ib_uverbs_lookup_comp_file(cmd.comp_channel);

uobj = kmalloc(sizeof *uobj, GFP_KERNEL);
if (!uobj)
return -ENOMEM;

if (cmd.comp_channel >= 0) {
ev_file = ib_uverbs_lookup_comp_file(cmd.comp_channel);
if (!ev_file) {
ret = -EINVAL;
goto err;
}
}

uobj->uobject.user_handle = cmd.user_handle;
uobj->uobject.context = file->ucontext;
uobj->uverbs_file = file;
Expand Down Expand Up @@ -664,6 +669,8 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file,
ib_destroy_cq(cq);

err:
if (ev_file)
ib_uverbs_release_ucq(file, ev_file, uobj);
kfree(uobj);
return ret;
}
Expand Down

0 comments on commit ac4e7b3

Please sign in to comment.