- use M_NOWAIT rather than M_WAITOK for malloc(9) to allocate RX buffer

in zstty_attach()
- check a return value of the malloc(9)

Taken from com.c, and somehow this seems to fix PR port-sun2/32420 on tme.
This commit is contained in:
tsutsui 2006-04-19 17:44:07 +00:00
parent 29f4f9865a
commit 91174570f2
1 changed files with 8 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: z8530tty.c,v 1.105 2006/03/29 04:16:49 thorpej Exp $ */
/* $NetBSD: z8530tty.c,v 1.106 2006/04/19 17:44:07 tsutsui Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998, 1999
@ -137,7 +137,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.105 2006/03/29 04:16:49 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.106 2006/04/19 17:44:07 tsutsui Exp $");
#include "opt_kgdb.h"
#include "opt_ntp.h"
@ -410,7 +410,12 @@ zstty_attach(parent, self, aux)
tty_attach(tp);
zst->zst_tty = tp;
zst->zst_rbuf = malloc(zstty_rbuf_size << 1, M_DEVBUF, M_WAITOK);
zst->zst_rbuf = malloc(zstty_rbuf_size << 1, M_DEVBUF, M_NOWAIT);
if (zst->zst_rbuf == NULL) {
aprint_error("%s: unable to allocate ring buffer\n",
zst->zst_dev.dv_xname);
return;
}
zst->zst_ebuf = zst->zst_rbuf + (zstty_rbuf_size << 1);
/* Disable the high water mark. */
zst->zst_r_hiwat = 0;