diff options
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/core/user_mad.c | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c index f5ed36c2a06c..d61f544f19e0 100644 --- a/drivers/infiniband/core/user_mad.c +++ b/drivers/infiniband/core/user_mad.c | |||
@@ -116,7 +116,6 @@ struct ib_umad_file { | |||
116 | spinlock_t recv_lock; | 116 | spinlock_t recv_lock; |
117 | wait_queue_head_t recv_wait; | 117 | wait_queue_head_t recv_wait; |
118 | struct ib_mad_agent *agent[IB_UMAD_MAX_AGENTS]; | 118 | struct ib_mad_agent *agent[IB_UMAD_MAX_AGENTS]; |
119 | struct ib_mr *mr[IB_UMAD_MAX_AGENTS]; | ||
120 | }; | 119 | }; |
121 | 120 | ||
122 | struct ib_umad_packet { | 121 | struct ib_umad_packet { |
@@ -505,29 +504,16 @@ found: | |||
505 | goto out; | 504 | goto out; |
506 | } | 505 | } |
507 | 506 | ||
508 | file->mr[agent_id] = ib_get_dma_mr(agent->qp->pd, IB_ACCESS_LOCAL_WRITE); | ||
509 | if (IS_ERR(file->mr[agent_id])) { | ||
510 | ret = -ENOMEM; | ||
511 | goto err; | ||
512 | } | ||
513 | |||
514 | if (put_user(agent_id, | 507 | if (put_user(agent_id, |
515 | (u32 __user *) (arg + offsetof(struct ib_user_mad_reg_req, id)))) { | 508 | (u32 __user *) (arg + offsetof(struct ib_user_mad_reg_req, id)))) { |
516 | ret = -EFAULT; | 509 | ret = -EFAULT; |
517 | goto err_mr; | 510 | ib_unregister_mad_agent(agent); |
511 | goto out; | ||
518 | } | 512 | } |
519 | 513 | ||
520 | file->agent[agent_id] = agent; | 514 | file->agent[agent_id] = agent; |
521 | ret = 0; | 515 | ret = 0; |
522 | 516 | ||
523 | goto out; | ||
524 | |||
525 | err_mr: | ||
526 | ib_dereg_mr(file->mr[agent_id]); | ||
527 | |||
528 | err: | ||
529 | ib_unregister_mad_agent(agent); | ||
530 | |||
531 | out: | 517 | out: |
532 | up_write(&file->port->mutex); | 518 | up_write(&file->port->mutex); |
533 | return ret; | 519 | return ret; |
@@ -536,7 +522,6 @@ out: | |||
536 | static int ib_umad_unreg_agent(struct ib_umad_file *file, unsigned long arg) | 522 | static int ib_umad_unreg_agent(struct ib_umad_file *file, unsigned long arg) |
537 | { | 523 | { |
538 | struct ib_mad_agent *agent = NULL; | 524 | struct ib_mad_agent *agent = NULL; |
539 | struct ib_mr *mr = NULL; | ||
540 | u32 id; | 525 | u32 id; |
541 | int ret = 0; | 526 | int ret = 0; |
542 | 527 | ||
@@ -551,16 +536,13 @@ static int ib_umad_unreg_agent(struct ib_umad_file *file, unsigned long arg) | |||
551 | } | 536 | } |
552 | 537 | ||
553 | agent = file->agent[id]; | 538 | agent = file->agent[id]; |
554 | mr = file->mr[id]; | ||
555 | file->agent[id] = NULL; | 539 | file->agent[id] = NULL; |
556 | 540 | ||
557 | out: | 541 | out: |
558 | up_write(&file->port->mutex); | 542 | up_write(&file->port->mutex); |
559 | 543 | ||
560 | if (agent) { | 544 | if (agent) |
561 | ib_unregister_mad_agent(agent); | 545 | ib_unregister_mad_agent(agent); |
562 | ib_dereg_mr(mr); | ||
563 | } | ||
564 | 546 | ||
565 | return ret; | 547 | return ret; |
566 | } | 548 | } |
@@ -629,10 +611,8 @@ static int ib_umad_close(struct inode *inode, struct file *filp) | |||
629 | int i; | 611 | int i; |
630 | 612 | ||
631 | for (i = 0; i < IB_UMAD_MAX_AGENTS; ++i) | 613 | for (i = 0; i < IB_UMAD_MAX_AGENTS; ++i) |
632 | if (file->agent[i]) { | 614 | if (file->agent[i]) |
633 | ib_unregister_mad_agent(file->agent[i]); | 615 | ib_unregister_mad_agent(file->agent[i]); |
634 | ib_dereg_mr(file->mr[i]); | ||
635 | } | ||
636 | 616 | ||
637 | list_for_each_entry_safe(packet, tmp, &file->recv_list, list) | 617 | list_for_each_entry_safe(packet, tmp, &file->recv_list, list) |
638 | kfree(packet); | 618 | kfree(packet); |
@@ -872,7 +852,6 @@ static void ib_umad_kill_port(struct ib_umad_port *port) | |||
872 | for (id = 0; id < IB_UMAD_MAX_AGENTS; ++id) { | 852 | for (id = 0; id < IB_UMAD_MAX_AGENTS; ++id) { |
873 | if (!file->agent[id]) | 853 | if (!file->agent[id]) |
874 | continue; | 854 | continue; |
875 | ib_dereg_mr(file->mr[id]); | ||
876 | ib_unregister_mad_agent(file->agent[id]); | 855 | ib_unregister_mad_agent(file->agent[id]); |
877 | file->agent[id] = NULL; | 856 | file->agent[id] = NULL; |
878 | } | 857 | } |