diff options
author | glebius <glebius@FreeBSD.org> | 2006-01-14 13:04:08 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2006-01-14 13:04:08 +0000 |
commit | b2c3d92e4077c5c3e2b220cf703fd833873689e1 (patch) | |
tree | a4bf6ce7861721ae220021697c3d7716b6654343 /sys/netinet/tcp_syncache.c | |
parent | 50771bd3de0d065f1a16c1b2088245271d0ae327 (diff) | |
download | FreeBSD-src-b2c3d92e4077c5c3e2b220cf703fd833873689e1.zip FreeBSD-src-b2c3d92e4077c5c3e2b220cf703fd833873689e1.tar.gz |
UMA can return NULL not only in case when our zone is full, but
also in case of generic memory shortage. In the latter case we may
not find an old entry.
Found with: Coverity Prevent(tm)
Diffstat (limited to 'sys/netinet/tcp_syncache.c')
-rw-r--r-- | sys/netinet/tcp_syncache.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index 87d919a..13f7320 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -886,15 +886,21 @@ syncache_add(inc, to, th, sop, m) * Treat this as if the cache was full; drop the oldest * entry and insert the new one. */ + tcpstat.tcps_sc_zonefail++; /* NB: guarded by INP_INFO_WLOCK(&tcbinfo) */ for (i = SYNCACHE_MAXREXMTS; i >= 0; i--) { sc = TAILQ_FIRST(&tcp_syncache.timerq[i]); if (sc != NULL) break; } + if (sc == NULL) { + /* Generic memory failure. */ + if (ipopts) + (void) m_free(ipopts); + return (0); + } sc->sc_tp->ts_recent = ticks; syncache_drop(sc, NULL); - tcpstat.tcps_sc_zonefail++; sc = uma_zalloc(tcp_syncache.zone, M_NOWAIT); if (sc == NULL) { if (ipopts) |