net/cxgbevf: fix illegal memory access when freeing MPS TCAM
authorRahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Fri, 9 Nov 2018 07:56:28 +0000 (13:26 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 13 Nov 2018 23:35:53 +0000 (00:35 +0100)
Individual MPS TCAM entries are not allocated as separate entities.
All entries are allocated once as an array. So, fix bug with attempting
to free illegal memory location.

Also add missing MPS TCAM initialization for CXGBEVF.

Fixes: 6fda3f0ddda9 ("net/cxgbe: add API to program hardware MPS table")

Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
drivers/net/cxgbe/cxgbevf_main.c
drivers/net/cxgbe/mps_tcam.c

index 6223e12..61bd851 100644 (file)
@@ -11,6 +11,7 @@
 #include "t4_regs.h"
 #include "t4_msg.h"
 #include "cxgbe.h"
+#include "mps_tcam.h"
 
 /*
  * Figure out how many Ports and Queue Sets we can support.  This depends on
@@ -271,6 +272,11 @@ allocate_mac:
        print_adapter_info(adapter);
        print_port_info(adapter);
 
+       adapter->mpstcam = t4_init_mpstcam(adapter);
+       if (!adapter->mpstcam)
+               dev_warn(adapter,
+                        "VF could not allocate mps tcam table. Continuing\n");
+
        err = init_rss(adapter);
        if (err)
                goto out_free;
index 02ec69a..71c8070 100644 (file)
@@ -236,8 +236,6 @@ struct mpstcam_table *t4_init_mpstcam(struct adapter *adap)
 
 void t4_cleanup_mpstcam(struct adapter *adap)
 {
-       if (adap->mpstcam) {
-               t4_os_free(adap->mpstcam->entry);
+       if (adap->mpstcam)
                t4_os_free(adap->mpstcam);
-       }
 }