Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 13769
b: refs/heads/master
c: 2f76e82
h: refs/heads/master
i:
  13767: 0ee065e
v: v3
  • Loading branch information
Roland Dreier committed Nov 10, 2005
1 parent 19efdd4 commit cf8643d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1732b0ef3b3a02e3df328086fb3018741c5476da
refs/heads/master: 2f76e82947b977a1008cfd2868351a701c93c69c
29 changes: 17 additions & 12 deletions trunk/drivers/infiniband/core/user_mad.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,6 @@ static int ib_umad_reg_agent(struct ib_umad_file *file, unsigned long arg)
goto out;
}

file->agent[agent_id] = agent;

file->mr[agent_id] = ib_get_dma_mr(agent->qp->pd, IB_ACCESS_LOCAL_WRITE);
if (IS_ERR(file->mr[agent_id])) {
ret = -ENOMEM;
Expand All @@ -519,14 +517,15 @@ static int ib_umad_reg_agent(struct ib_umad_file *file, unsigned long arg)
goto err_mr;
}

file->agent[agent_id] = agent;
ret = 0;

goto out;

err_mr:
ib_dereg_mr(file->mr[agent_id]);

err:
file->agent[agent_id] = NULL;
ib_unregister_mad_agent(agent);

out:
Expand All @@ -536,27 +535,33 @@ static int ib_umad_reg_agent(struct ib_umad_file *file, unsigned long arg)

static int ib_umad_unreg_agent(struct ib_umad_file *file, unsigned long arg)
{
struct ib_mad_agent *agent = NULL;
struct ib_mr *mr = NULL;
u32 id;
int ret = 0;

down_write(&file->port->mutex);
if (get_user(id, (u32 __user *) arg))
return -EFAULT;

if (get_user(id, (u32 __user *) arg)) {
ret = -EFAULT;
goto out;
}
down_write(&file->port->mutex);

if (id < 0 || id >= IB_UMAD_MAX_AGENTS || !file->agent[id]) {
ret = -EINVAL;
goto out;
}

ib_dereg_mr(file->mr[id]);
ib_unregister_mad_agent(file->agent[id]);
agent = file->agent[id];
mr = file->mr[id];
file->agent[id] = NULL;

out:
up_write(&file->port->mutex);

if (agent) {
ib_unregister_mad_agent(agent);
ib_dereg_mr(mr);
}

return ret;
}

Expand Down Expand Up @@ -623,16 +628,16 @@ static int ib_umad_close(struct inode *inode, struct file *filp)
struct ib_umad_packet *packet, *tmp;
int i;

down_write(&file->port->mutex);
for (i = 0; i < IB_UMAD_MAX_AGENTS; ++i)
if (file->agent[i]) {
ib_dereg_mr(file->mr[i]);
ib_unregister_mad_agent(file->agent[i]);
ib_dereg_mr(file->mr[i]);
}

list_for_each_entry_safe(packet, tmp, &file->recv_list, list)
kfree(packet);

down_write(&file->port->mutex);
list_del(&file->port_list);
up_write(&file->port->mutex);

Expand Down

0 comments on commit cf8643d

Please sign in to comment.