Commit 56c202d6 authored by Roland Dreier's avatar Roland Dreier

[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: default avatarRoland Dreier <rolandd@cisco.com>
parent 305a7e87
...@@ -583,10 +583,16 @@ int ib_sa_path_rec_get(struct ib_device *device, u8 port_num, ...@@ -583,10 +583,16 @@ int ib_sa_path_rec_get(struct ib_device *device, u8 port_num,
{ {
struct ib_sa_path_query *query; struct ib_sa_path_query *query;
struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client); struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
struct ib_sa_port *port = &sa_dev->port[port_num - sa_dev->start_port]; struct ib_sa_port *port;
struct ib_mad_agent *agent = port->agent; struct ib_mad_agent *agent;
int ret; int ret;
if (!sa_dev)
return -ENODEV;
port = &sa_dev->port[port_num - sa_dev->start_port];
agent = port->agent;
query = kmalloc(sizeof *query, gfp_mask); query = kmalloc(sizeof *query, gfp_mask);
if (!query) if (!query)
return -ENOMEM; return -ENOMEM;
...@@ -685,10 +691,16 @@ int ib_sa_service_rec_query(struct ib_device *device, u8 port_num, u8 method, ...@@ -685,10 +691,16 @@ int ib_sa_service_rec_query(struct ib_device *device, u8 port_num, u8 method,
{ {
struct ib_sa_service_query *query; struct ib_sa_service_query *query;
struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client); struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
struct ib_sa_port *port = &sa_dev->port[port_num - sa_dev->start_port]; struct ib_sa_port *port;
struct ib_mad_agent *agent = port->agent; struct ib_mad_agent *agent;
int ret; int ret;
if (!sa_dev)
return -ENODEV;
port = &sa_dev->port[port_num - sa_dev->start_port];
agent = port->agent;
if (method != IB_MGMT_METHOD_GET && if (method != IB_MGMT_METHOD_GET &&
method != IB_MGMT_METHOD_SET && method != IB_MGMT_METHOD_SET &&
method != IB_SA_METHOD_DELETE) method != IB_SA_METHOD_DELETE)
...@@ -768,10 +780,16 @@ int ib_sa_mcmember_rec_query(struct ib_device *device, u8 port_num, ...@@ -768,10 +780,16 @@ int ib_sa_mcmember_rec_query(struct ib_device *device, u8 port_num,
{ {
struct ib_sa_mcmember_query *query; struct ib_sa_mcmember_query *query;
struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client); struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
struct ib_sa_port *port = &sa_dev->port[port_num - sa_dev->start_port]; struct ib_sa_port *port;
struct ib_mad_agent *agent = port->agent; struct ib_mad_agent *agent;
int ret; int ret;
if (!sa_dev)
return -ENODEV;
port = &sa_dev->port[port_num - sa_dev->start_port];
agent = port->agent;
query = kmalloc(sizeof *query, gfp_mask); query = kmalloc(sizeof *query, gfp_mask);
if (!query) if (!query)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment