diff options
| author | 2003-06-18 22:47:54 +0000 | |
|---|---|---|
| committer | 2003-06-18 22:47:54 +0000 | |
| commit | fccff59b62804f9b35dcecde33c37a4fa7533929 (patch) | |
| tree | ac3e6ac9daf81fa5c135ac3aa3d193e7d3c4965c /sys/net/bpf.c | |
| parent | - store builtin name as definition for builtin macros. (diff) | |
| download | wireguard-openbsd-fccff59b62804f9b35dcecde33c37a4fa7533929.tar.xz wireguard-openbsd-fccff59b62804f9b35dcecde33c37a4fa7533929.zip | |
Do not panic on no memory available when allocating bufs, pass ENOBUFS
to userland instead.
fixes PRs 2235, 2236 and 2640
from Otto Moerbeek <otto@drijf.net>
ok frantzen@, tedu@, deraadt@
Diffstat (limited to 'sys/net/bpf.c')
| -rw-r--r-- | sys/net/bpf.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 536cf0a25da..0efa7aa8b6d 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.35 2003/06/02 23:28:11 millert Exp $ */ +/* $OpenBSD: bpf.c,v 1.36 2003/06/18 22:47:54 henning Exp $ */ /* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */ /* @@ -1205,8 +1205,14 @@ int bpf_allocbufs(d) register struct bpf_d *d; { - d->bd_fbuf = (caddr_t)malloc(d->bd_bufsize, M_DEVBUF, M_WAITOK); - d->bd_sbuf = (caddr_t)malloc(d->bd_bufsize, M_DEVBUF, M_WAITOK); + d->bd_fbuf = (caddr_t)malloc(d->bd_bufsize, M_DEVBUF, M_NOWAIT); + if (d->bd_fbuf == NULL) + return (ENOBUFS); + d->bd_sbuf = (caddr_t)malloc(d->bd_bufsize, M_DEVBUF, M_NOWAIT); + if (d->bd_sbuf == NULL) { + free(d->bd_fbuf, M_DEVBUF); + return (ENOBUFS); + } d->bd_slen = 0; d->bd_hlen = 0; return (0); |
