Author: slavash
Date: Wed Dec  5 13:20:51 2018
New Revision: 341526
URL: https://svnweb.freebsd.org/changeset/base/341526

Log:
  ibcore: Fix an array index check
  
  The array ib_mad_mgmt_class_table.method_table has MAX_MGMT_CLASS
  (80) elements. Hence compare the array index with that value instead
  of with IB_MGMT_MAX_METHODS (128). This patch avoids that Coverity
  reports the following:
  
  Overrunning array class->method_table of 80 8-byte elements at element index 
127
  (byte offset 1016) using index convert_mgmt_class(mad_hdr->mgmt_class)
  (which evaluates to 127).
  
  Linux commit:
  2fe2f378dd45847d2643638c07a7658822087836
  
  Submitted by:   hselasky@
  Approved by:    hselasky (mentor)
  MFC after:      1 week
  Sponsored by:   Mellanox Technologies

Modified:
  head/sys/ofed/drivers/infiniband/core/ib_mad.c

Modified: head/sys/ofed/drivers/infiniband/core/ib_mad.c
==============================================================================
--- head/sys/ofed/drivers/infiniband/core/ib_mad.c      Wed Dec  5 13:20:22 
2018        (r341525)
+++ head/sys/ofed/drivers/infiniband/core/ib_mad.c      Wed Dec  5 13:20:51 
2018        (r341526)
@@ -1753,7 +1753,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)];
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to