diff options
author | 2010-12-15 03:34:33 +0000 | |
---|---|---|
committer | 2010-12-15 03:34:33 +0000 | |
commit | d14ac25b304d09e2d77c89464bcdb46981d0b482 (patch) | |
tree | bab9a5fd1e8458e53646b35e7cfa4a9e692480f6 | |
parent | don't delay if the device is dying (diff) | |
download | wireguard-openbsd-d14ac25b304d09e2d77c89464bcdb46981d0b482.tar.xz wireguard-openbsd-d14ac25b304d09e2d77c89464bcdb46981d0b482.zip |
revert the malloc change, as it meant dropping events before the device is
opened. keep the array expansion. ok deraadt
-rw-r--r-- | sys/dev/hotplug.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/sys/dev/hotplug.c b/sys/dev/hotplug.c index 5e03e3b5713..0013b67d0b5 100644 --- a/sys/dev/hotplug.c +++ b/sys/dev/hotplug.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hotplug.c,v 1.10 2010/12/02 04:12:35 tedu Exp $ */ +/* $OpenBSD: hotplug.c,v 1.11 2010/12/15 03:34:33 tedu Exp $ */ /* * Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org> * @@ -26,14 +26,13 @@ #include <sys/fcntl.h> #include <sys/hotplug.h> #include <sys/ioctl.h> -#include <sys/malloc.h> #include <sys/poll.h> #include <sys/vnode.h> #define HOTPLUG_MAXEVENTS 64 static int opened; -static struct hotplug_event *evqueue; +static struct hotplug_event evqueue[HOTPLUG_MAXEVENTS]; static int evqueue_head, evqueue_tail, evqueue_count; static struct selinfo hotplug_sel; @@ -89,8 +88,6 @@ hotplug_put_event(struct hotplug_event *he) printf("hotplug: event lost, queue full\n"); return (1); } - if (!evqueue) - return (1); evqueue[evqueue_head] = *he; evqueue_head = EVQUEUE_NEXT(evqueue_head); @@ -122,22 +119,12 @@ hotplug_get_event(struct hotplug_event *he) int hotplugopen(dev_t dev, int flag, int mode, struct proc *p) { - struct hotplug_event *q; - if (minor(dev) != 0) return (ENXIO); if ((flag & FWRITE)) return (EPERM); if (opened) return (EBUSY); - if (!evqueue) { - q = malloc(sizeof(*q) * HOTPLUG_MAXEVENTS, M_DEVBUF, M_WAITOK); - if (opened) { - free(q, M_DEVBUF); - return (EBUSY); - } - evqueue = q; - } opened = 1; return (0); } |