Author: np
Date: Fri Mar  6 19:56:12 2020
New Revision: 358717
URL: https://svnweb.freebsd.org/changeset/base/358717

Log:
  cxgbe/t4_tom: Do not uninitialize a toepcb that has not been initialized.
  
  This fixes the following panic:
  --- trap 0xc, rip = 0xffffffff80c00411, rsp = 0xfffffe0025192840, rbp = 
0xfffffe0025192860 ---
  vmem_xfree() at vmem_xfree+0xd1/frame 0xfffffe0025192860
  tls_uninit_toep() at tls_uninit_toep+0x78/frame 0xfffffe0025192880
  free_toepcb() at free_toepcb+0x32/frame 0xfffffe00251928a0
  t4_connect() at t4_connect+0x3be/frame 0xfffffe0025192950
  tcp_offload_connect() at tcp_offload_connect+0xa4/frame 0xfffffe0025192990
  tcp_usr_connect() at tcp_usr_connect+0xec/frame 0xfffffe00251929f0
  soconnect() at soconnect+0xae/frame 0xfffffe0025192a30
  kern_connectat() at kern_connectat+0xe2/frame 0xfffffe0025192a90
  sys_connect() at sys_connect+0x75/frame 0xfffffe0025192ad0
  amd64_syscall() at amd64_syscall+0x137/frame 0xfffffe0025192bf0
  fast_syscall_common() at fast_syscall_common+0x101/frame 0xfffffe0025192bf0
  --- syscall (98, FreeBSD ELF64, sys_connect), rip = 0x8008e9d8a, rsp = 
0x7fffffffc0f8, rbp = 0x7fffffffc130 ---
  
  Reviewed by:  jhb@
  MFC after:    3 days
  Sponsored by: Chelsio Communications
  Differential Revision:        https://reviews.freebsd.org/D23989

Modified:
  head/sys/dev/cxgbe/tom/t4_tom.c
  head/sys/dev/cxgbe/tom/t4_tom.h

Modified: head/sys/dev/cxgbe/tom/t4_tom.c
==============================================================================
--- head/sys/dev/cxgbe/tom/t4_tom.c     Fri Mar  6 19:10:00 2020        
(r358716)
+++ head/sys/dev/cxgbe/tom/t4_tom.c     Fri Mar  6 19:56:12 2020        
(r358717)
@@ -187,6 +187,8 @@ init_toepcb(struct vi_info *vi, struct toepcb *toep)
        if (ulp_mode(toep) == ULP_MODE_TCPDDP)
                ddp_init_toep(toep);
 
+       toep->flags |= TPF_INITIALIZED;
+
        return (0);
 }
 
@@ -210,9 +212,11 @@ free_toepcb(struct toepcb *toep)
        KASSERT(!(toep->flags & TPF_CPL_PENDING),
            ("%s: CPL pending", __func__));
 
-       if (ulp_mode(toep) == ULP_MODE_TCPDDP)
-               ddp_uninit_toep(toep);
-       tls_uninit_toep(toep);
+       if (toep->flags & TPF_INITIALIZED) {
+               if (ulp_mode(toep) == ULP_MODE_TCPDDP)
+                       ddp_uninit_toep(toep);
+               tls_uninit_toep(toep);
+       }
        free(toep, M_CXGBE);
 }
 

Modified: head/sys/dev/cxgbe/tom/t4_tom.h
==============================================================================
--- head/sys/dev/cxgbe/tom/t4_tom.h     Fri Mar  6 19:10:00 2020        
(r358716)
+++ head/sys/dev/cxgbe/tom/t4_tom.h     Fri Mar  6 19:56:12 2020        
(r358717)
@@ -73,6 +73,7 @@ enum {
        TPF_SYNQE_EXPANDED = (1 << 9),  /* toepcb ready, tid context updated */
        TPF_FORCE_CREDITS  = (1 << 10), /* always send credits */
        TPF_KTLS           = (1 << 11), /* send TLS records from KTLS */
+       TPF_INITIALIZED    = (1 << 12), /* init_toepcb has been called */
 };
 
 enum {
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to