summaryrefslogtreecommitdiff
path: root/drivers/infiniband/core/uverbs_cmd.c
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2005-10-28 15:38:26 -0700
committerRoland Dreier <rolandd@cisco.com>2005-10-28 15:38:26 -0700
commit70a30e16a8a9d22396a4d1e96af86e43594df584 (patch)
tree0d8582567c62f7929620ec03128c79f9d8c65a58 /drivers/infiniband/core/uverbs_cmd.c
parenta74968f8c3b1166cfe0942901b56165f06ab6f60 (diff)
[IB] uverbs: Fix device lifetime problems
Move ib_uverbs module to using cdev_alloc() and class_device_create() so that we can handle device lifetime properly. Now we can make sure we keep all of our data structures around until the last way to reach them is gone. Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/core/uverbs_cmd.c')
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c38
1 files changed, 5 insertions, 33 deletions
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 14583bb6e2c0..8c89abc8c764 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -35,6 +35,7 @@
*/
#include <linux/file.h>
+#include <linux/fs.h>
#include <asm/uaccess.h>
@@ -114,7 +115,7 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
kref_get(&file->async_file->ref);
kref_get(&file->ref);
- file->ucontext = ucontext;
+ file->ucontext = ucontext;
fd_install(resp.async_fd, filp);
@@ -761,7 +762,6 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
struct ib_cq *cq;
struct ib_ucq_object *uobj;
struct ib_uverbs_event_file *ev_file;
- struct ib_uverbs_event *evt, *tmp;
u64 user_handle;
int ret = -EINVAL;
@@ -790,23 +790,7 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
list_del(&uobj->uobject.list);
up(&file->mutex);
- if (ev_file) {
- spin_lock_irq(&ev_file->lock);
- list_for_each_entry_safe(evt, tmp, &uobj->comp_list, obj_list) {
- list_del(&evt->list);
- kfree(evt);
- }
- spin_unlock_irq(&ev_file->lock);
-
- kref_put(&ev_file->ref, ib_uverbs_release_event_file);
- }
-
- spin_lock_irq(&file->async_file->lock);
- list_for_each_entry_safe(evt, tmp, &uobj->async_list, obj_list) {
- list_del(&evt->list);
- kfree(evt);
- }
- spin_unlock_irq(&file->async_file->lock);
+ ib_uverbs_release_ucq(file, ev_file, uobj);
resp.comp_events_reported = uobj->comp_events_reported;
resp.async_events_reported = uobj->async_events_reported;
@@ -1043,7 +1027,6 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
struct ib_uverbs_destroy_qp_resp resp;
struct ib_qp *qp;
struct ib_uevent_object *uobj;
- struct ib_uverbs_event *evt, *tmp;
int ret = -EINVAL;
if (copy_from_user(&cmd, buf, sizeof cmd))
@@ -1069,12 +1052,7 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
list_del(&uobj->uobject.list);
up(&file->mutex);
- spin_lock_irq(&file->async_file->lock);
- list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) {
- list_del(&evt->list);
- kfree(evt);
- }
- spin_unlock_irq(&file->async_file->lock);
+ ib_uverbs_release_uevent(file, uobj);
resp.events_reported = uobj->events_reported;
@@ -1741,7 +1719,6 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
struct ib_uverbs_destroy_srq_resp resp;
struct ib_srq *srq;
struct ib_uevent_object *uobj;
- struct ib_uverbs_event *evt, *tmp;
int ret = -EINVAL;
if (copy_from_user(&cmd, buf, sizeof cmd))
@@ -1767,12 +1744,7 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
list_del(&uobj->uobject.list);
up(&file->mutex);
- spin_lock_irq(&file->async_file->lock);
- list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) {
- list_del(&evt->list);
- kfree(evt);
- }
- spin_unlock_irq(&file->async_file->lock);
+ ib_uverbs_release_uevent(file, uobj);
resp.events_reported = uobj->events_reported;