diff options
author | Roland Dreier <rolandd@cisco.com> | 2005-10-13 13:45:02 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2005-10-17 18:20:29 -0400 |
commit | 56c202d6e4f542468fe79b8a735cf128898b87fb (patch) | |
tree | 3080b34f6080d71b88ae26f665b5e23d7f485c69 /drivers/infiniband | |
parent | 305a7e87055dde2466a855c24ef51a606915d149 (diff) |
[IB] fail SA queries if device initialization failed
If the SA query module's initialization fails for a device, then that
device won't have a struct ib_sa_device associated. We should fail SA
queries in that case, rather than blindly dereferencing the NULL
pointer we get back from ib_get_client_data().
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/core/sa_query.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c index 262618210c1c..a2c4234ca8a3 100644 --- a/drivers/infiniband/core/sa_query.c +++ b/drivers/infiniband/core/sa_query.c | |||
@@ -583,10 +583,16 @@ int ib_sa_path_rec_get(struct ib_device *device, u8 port_num, | |||
583 | { | 583 | { |
584 | struct ib_sa_path_query *query; | 584 | struct ib_sa_path_query *query; |
585 | struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client); | 585 | struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client); |
586 | struct ib_sa_port *port = &sa_dev->port[port_num - sa_dev->start_port]; | 586 | struct ib_sa_port *port; |
587 | struct ib_mad_agent *agent = port->agent; | 587 | struct ib_mad_agent *agent; |
588 | int ret; | 588 | int ret; |
589 | 589 | ||
590 | if (!sa_dev) | ||
591 | return -ENODEV; | ||
592 | |||
593 | port = &sa_dev->port[port_num - sa_dev->start_port]; | ||
594 | agent = port->agent; | ||
595 | |||
590 | query = kmalloc(sizeof *query, gfp_mask); | 596 | query = kmalloc(sizeof *query, gfp_mask); |
591 | if (!query) | 597 | if (!query) |
592 | return -ENOMEM; | 598 | return -ENOMEM; |
@@ -685,10 +691,16 @@ int ib_sa_service_rec_query(struct ib_device *device, u8 port_num, u8 method, | |||
685 | { | 691 | { |
686 | struct ib_sa_service_query *query; | 692 | struct ib_sa_service_query *query; |
687 | struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client); | 693 | struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client); |
688 | struct ib_sa_port *port = &sa_dev->port[port_num - sa_dev->start_port]; | 694 | struct ib_sa_port *port; |
689 | struct ib_mad_agent *agent = port->agent; | 695 | struct ib_mad_agent *agent; |
690 | int ret; | 696 | int ret; |
691 | 697 | ||
698 | if (!sa_dev) | ||
699 | return -ENODEV; | ||
700 | |||
701 | port = &sa_dev->port[port_num - sa_dev->start_port]; | ||
702 | agent = port->agent; | ||
703 | |||
692 | if (method != IB_MGMT_METHOD_GET && | 704 | if (method != IB_MGMT_METHOD_GET && |
693 | method != IB_MGMT_METHOD_SET && | 705 | method != IB_MGMT_METHOD_SET && |
694 | method != IB_SA_METHOD_DELETE) | 706 | method != IB_SA_METHOD_DELETE) |
@@ -768,10 +780,16 @@ int ib_sa_mcmember_rec_query(struct ib_device *device, u8 port_num, | |||
768 | { | 780 | { |
769 | struct ib_sa_mcmember_query *query; | 781 | struct ib_sa_mcmember_query *query; |
770 | struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client); | 782 | struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client); |
771 | struct ib_sa_port *port = &sa_dev->port[port_num - sa_dev->start_port]; | 783 | struct ib_sa_port *port; |
772 | struct ib_mad_agent *agent = port->agent; | 784 | struct ib_mad_agent *agent; |
773 | int ret; | 785 | int ret; |
774 | 786 | ||
787 | if (!sa_dev) | ||
788 | return -ENODEV; | ||
789 | |||
790 | port = &sa_dev->port[port_num - sa_dev->start_port]; | ||
791 | agent = port->agent; | ||
792 | |||
775 | query = kmalloc(sizeof *query, gfp_mask); | 793 | query = kmalloc(sizeof *query, gfp_mask); |
776 | if (!query) | 794 | if (!query) |
777 | return -ENOMEM; | 795 | return -ENOMEM; |