summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbz <bz@FreeBSD.org>2007-06-16 00:15:14 +0000
committerbz <bz@FreeBSD.org>2007-06-16 00:15:14 +0000
commite1f2e7690497be9f169ae2ca111f08881f575df0 (patch)
tree8e8063434abe72ae4399a1d125657195d69e2927
parent2e4e9b90cb613b32969504f14642838cad9d5f31 (diff)
downloadFreeBSD-src-e1f2e7690497be9f169ae2ca111f08881f575df0.zip
FreeBSD-src-e1f2e7690497be9f169ae2ca111f08881f575df0.tar.gz
In case of failure we can directly return ENOBUFS because
'result' is still NULL and we do not need to free anything. That allows us to gc the entire goto parts and a now unused variable. Found with: Coverity Prevent(tm) CID: 2519
-rw-r--r--sys/netipsec/key.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c
index daf539a..bd25513 100644
--- a/sys/netipsec/key.c
+++ b/sys/netipsec/key.c
@@ -2259,7 +2259,6 @@ key_spdacquire(sp)
{
struct mbuf *result = NULL, *m;
struct secspacq *newspacq;
- int error;
IPSEC_ASSERT(sp != NULL, ("null secpolicy"));
IPSEC_ASSERT(sp->req == NULL, ("policy exists"));
@@ -2287,10 +2286,9 @@ key_spdacquire(sp)
/* create new sadb_msg to reply. */
m = key_setsadbmsg(SADB_X_SPDACQUIRE, 0, 0, 0, 0, 0);
- if (!m) {
- error = ENOBUFS;
- goto fail;
- }
+ if (!m)
+ return ENOBUFS;
+
result = m;
result->m_pkthdr.len = 0;
@@ -2301,11 +2299,6 @@ key_spdacquire(sp)
PFKEY_UNIT64(result->m_pkthdr.len);
return key_sendup_mbuf(NULL, m, KEY_SENDUP_REGISTERED);
-
-fail:
- if (result)
- m_freem(result);
- return error;
}
/*
OpenPOWER on IntegriCloud