summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2007-01-07 13:28:04 +0000
committermiod <miod@openbsd.org>2007-01-07 13:28:04 +0000
commit17324ca640452b3e86d0aa6643d6e07d3a6e35a4 (patch)
tree85b2d19fc86481ca58798d99ecb4db6fea84121d
parentSpacing, comments. (diff)
downloadwireguard-openbsd-17324ca640452b3e86d0aa6643d6e07d3a6e35a4.tar.xz
wireguard-openbsd-17324ca640452b3e86d0aa6643d6e07d3a6e35a4.zip
In wsscreen_attach(), allow wsemul->attach to fail (returning NULL) if the
screen is not the console.
-rw-r--r--sys/dev/wscons/wsdisplay.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c
index eba6c54609f..d3a17233f2d 100644
--- a/sys/dev/wscons/wsdisplay.c
+++ b/sys/dev/wscons/wsdisplay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsdisplay.c,v 1.74 2006/12/02 18:16:14 miod Exp $ */
+/* $OpenBSD: wsdisplay.c,v 1.75 2007/01/07 13:28:04 miod Exp $ */
/* $NetBSD: wsdisplay.c,v 1.82 2005/02/27 00:27:52 perry Exp $ */
/*
@@ -288,26 +288,21 @@ wsscreen_attach(struct wsdisplay_softc *sc, int console, const char *emul,
* Tell the emulation about the callback argument.
* The other stuff is already there.
*/
- (*dconf->wsemul->attach)(1, 0, 0, 0, 0, scr, 0);
+ (void)(*dconf->wsemul->attach)(1, 0, 0, 0, 0, scr, 0);
} else { /* not console */
dconf = malloc(sizeof(struct wsscreen_internal),
M_DEVBUF, M_NOWAIT);
- if (dconf == NULL) {
- free(scr, M_DEVBUF);
- return (NULL);
- }
+ if (dconf == NULL)
+ goto fail;
dconf->emulops = type->textops;
dconf->emulcookie = cookie;
- if (dconf->emulops != NULL &&
- (dconf->wsemul = wsemul_pick(emul)) != NULL) {
- dconf->wsemulcookie =
- (*dconf->wsemul->attach)(0, type, cookie,
- ccol, crow, scr, defattr);
- } else {
- free(dconf, M_DEVBUF);
- free(scr, M_DEVBUF);
- return (NULL);
- }
+ if (dconf->emulops == NULL ||
+ (dconf->wsemul = wsemul_pick(emul)) == NULL)
+ goto fail;
+ dconf->wsemulcookie = (*dconf->wsemul->attach)(0, type, cookie,
+ ccol, crow, scr, defattr);
+ if (dconf->wsemulcookie == NULL)
+ goto fail;
dconf->scrdata = type;
}
@@ -329,6 +324,12 @@ wsscreen_attach(struct wsdisplay_softc *sc, int console, const char *emul,
scr->scr_rawkbd = 0;
#endif
return (scr);
+
+fail:
+ if (dconf != NULL)
+ free(dconf, M_DEVBUF);
+ free(scr, M_DEVBUF);
+ return (NULL);
}
void