mirror of
https://github.com/adulau/aha.git
synced 2024-12-29 04:06:22 +00:00
[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>
This commit is contained in:
parent
305a7e8705
commit
56c202d6e4
1 changed files with 24 additions and 6 deletions
|
@ -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_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_mad_agent *agent = port->agent;
|
||||
struct ib_sa_port *port;
|
||||
struct ib_mad_agent *agent;
|
||||
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);
|
||||
if (!query)
|
||||
return -ENOMEM;
|
||||
|
@ -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_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_mad_agent *agent = port->agent;
|
||||
struct ib_sa_port *port;
|
||||
struct ib_mad_agent *agent;
|
||||
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 &&
|
||||
method != IB_MGMT_METHOD_SET &&
|
||||
method != IB_SA_METHOD_DELETE)
|
||||
|
@ -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_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_mad_agent *agent = port->agent;
|
||||
struct ib_sa_port *port;
|
||||
struct ib_mad_agent *agent;
|
||||
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);
|
||||
if (!query)
|
||||
return -ENOMEM;
|
||||
|
|
Loading…
Reference in a new issue