⬢ DragonFlyBSD Kernel Audit
DF-3210 / fix.diff
← back to finding ↓ download raw
--- a/sys/vfs/nfs/krpc_subr.c
+++ b/sys/vfs/nfs/krpc_subr.c
@@ -435,7 +435,17 @@
 	}
 
  out:
-	if (mhead) m_freem(mhead);
+	if (mhead) {
+		m_freem(mhead);
+	} else if (*data) {
+		/*
+		 * Early error exit before the request was chained onto
+		 * mhead.  Callers (nfs_mountrpc.c md_mount/md_lookup_swap)
+		 * expect krpc_call to consume the request mbuf.
+		 */
+		m_freem(*data);
+		*data = NULL;
+	}
 	if (from) kfree(from, M_SONAME);
 	soclose(so, FNONBLOCK);
 	return error;