summaryrefslogtreecommitdiff
path: root/sys/dev/pci/ubsec.c
diff options
context:
space:
mode:
authorConstantine Sapuntzakis <csapuntz@cvs.openbsd.org>2001-03-25 07:59:26 +0000
committerConstantine Sapuntzakis <csapuntz@cvs.openbsd.org>2001-03-25 07:59:26 +0000
commit83da83282712ed7138ca50192c2996352cb99bcd (patch)
tree98ac8d553711f2fd33f945eaaf2316ed7b9282fa /sys/dev/pci/ubsec.c
parent222817b748cb9818e358bad83caea1a2e01e0aed (diff)
Fix potential dangling mbuf and potential double free. Thanks to Dawson and team
Diffstat (limited to 'sys/dev/pci/ubsec.c')
-rw-r--r--sys/dev/pci/ubsec.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/sys/dev/pci/ubsec.c b/sys/dev/pci/ubsec.c
index d90b7f708b9..b1c4769f57b 100644
--- a/sys/dev/pci/ubsec.c
+++ b/sys/dev/pci/ubsec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ubsec.c,v 1.40 2001/02/02 01:00:07 jason Exp $ */
+/* $OpenBSD: ubsec.c,v 1.41 2001/03/25 07:59:25 csapuntz Exp $ */
/*
* Copyright (c) 2000 Jason L. Wright (jason@thought.net)
@@ -592,10 +592,17 @@ ubsec_process(crp)
q->q_sesn = UBSEC_SESSION(crp->crp_sid);
ses = &sc->sc_sessions[q->q_sesn];
+ if (crp->crp_flags & CRYPTO_F_IMBUF) {
+ q->q_src_m = (struct mbuf *)crp->crp_buf;
+ q->q_dst_m = (struct mbuf *)crp->crp_buf;
+ } else {
+ err = EINVAL;
+ goto errout; /* XXX only handle mbufs right now */
+ }
+
q->q_mcr = (struct ubsec_mcr *)malloc(sizeof(struct ubsec_mcr),
M_DEVBUF, M_NOWAIT);
if (q->q_mcr == NULL) {
- free(q, M_DEVBUF);
err = ENOMEM;
goto errout;
}
@@ -607,14 +614,6 @@ ubsec_process(crp)
q->q_sc = sc;
q->q_crp = crp;
- if (crp->crp_flags & CRYPTO_F_IMBUF) {
- q->q_src_m = (struct mbuf *)crp->crp_buf;
- q->q_dst_m = (struct mbuf *)crp->crp_buf;
- } else {
- err = EINVAL;
- goto errout; /* XXX only handle mbufs right now */
- }
-
crd1 = crp->crp_desc;
if (crd1 == NULL) {
err = EINVAL;