drm/rockchip: dw-mipi: use phy_get_bus_width to fetch the lane_mbps for rk3368
[firefly-linux-kernel-4.4.55.git] / drivers / infiniband / core / mad.c
index 8d8af7a41a30fae4ceb520ce0d11b6f541905c96..8d84c563ba75351f053c223841c144e87afd80ec 100644 (file)
@@ -1745,7 +1745,7 @@ find_mad_agent(struct ib_mad_port_private *port_priv,
                        if (!class)
                                goto out;
                        if (convert_mgmt_class(mad_hdr->mgmt_class) >=
-                           IB_MGMT_MAX_METHODS)
+                           ARRAY_SIZE(class->method_table))
                                goto out;
                        method = class->method_table[convert_mgmt_class(
                                                        mad_hdr->mgmt_class)];
@@ -1811,6 +1811,11 @@ static int validate_mad(const struct ib_mad_hdr *mad_hdr,
                if (qp_num == 0)
                        valid = 1;
        } else {
+               /* CM attributes other than ClassPortInfo only use Send method */
+               if ((mad_hdr->mgmt_class == IB_MGMT_CLASS_CM) &&
+                   (mad_hdr->attr_id != IB_MGMT_CLASSPORTINFO_ATTR_ID) &&
+                   (mad_hdr->method != IB_MGMT_METHOD_SEND))
+                       goto out;
                /* Filter GSI packets sent to QP0 */
                if (qp_num != 0)
                        valid = 1;