|
@@ -1345,6 +1345,7 @@ EXPORT_SYMBOL(ib_init_ah_attr_from_path);
|
|
|
|
|
|
static int alloc_mad(struct ib_sa_query *query, gfp_t gfp_mask)
|
|
|
{
|
|
|
+ struct rdma_ah_attr ah_attr;
|
|
|
unsigned long flags;
|
|
|
|
|
|
spin_lock_irqsave(&query->port->ah_lock, flags);
|
|
@@ -1356,6 +1357,15 @@ static int alloc_mad(struct ib_sa_query *query, gfp_t gfp_mask)
|
|
|
query->sm_ah = query->port->sm_ah;
|
|
|
spin_unlock_irqrestore(&query->port->ah_lock, flags);
|
|
|
|
|
|
+ /*
|
|
|
+ * Always check if sm_ah has valid dlid assigned,
|
|
|
+ * before querying for class port info
|
|
|
+ */
|
|
|
+ if ((rdma_query_ah(query->sm_ah->ah, &ah_attr) < 0) ||
|
|
|
+ !rdma_is_valid_unicast_lid(&ah_attr)) {
|
|
|
+ kref_put(&query->sm_ah->ref, free_sm_ah);
|
|
|
+ return -EAGAIN;
|
|
|
+ }
|
|
|
query->mad_buf = ib_create_send_mad(query->port->agent, 1,
|
|
|
query->sm_ah->pkey_index,
|
|
|
0, IB_MGMT_SA_HDR, IB_MGMT_SA_DATA,
|