Module Name:    src
Committed By:   maya
Date:           Wed Jan 11 00:55:57 UTC 2017

Modified Files:
        src/sys/arch/x86/pci: if_vmx.c

Log Message:
we cannot guarantee that m_pulldown doesn't fail, as it may fail even
if temporarily out of memory, and it will free the mbuf in this scenario.

test for failure and return error if it happens.

CID 1396651

ok riastradh


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.17 src/sys/arch/x86/pci/if_vmx.c:1.18
--- src/sys/arch/x86/pci/if_vmx.c:1.17	Wed Jan 11 00:51:22 2017
+++ src/sys/arch/x86/pci/if_vmx.c	Wed Jan 11 00:55:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.17 2017/01/11 00:51:22 maya Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.18 2017/01/11 00:55:57 maya Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.17 2017/01/11 00:51:22 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.18 2017/01/11 00:55:57 maya Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -2554,6 +2554,10 @@ vmxnet3_txq_offload_ctx(struct vmxnet3_t
 
 	*csum_start = *start + csum_off;
 	mp = m_pulldown(m, 0, *csum_start + 2, &offp);
+	if (!mp) {
+		/* m is already freed */
+		return ENOBUFS;
+	}
 
 	if (m->m_pkthdr.csum_flags & (M_CSUM_TSOv4 | M_CSUM_TSOv6)) {
 		struct tcphdr *tcp;

Reply via email to