From d1fba4e7e50f3e6cad083c81d251939c436f3c58 Mon Sep 17 00:00:00 2001 From: thorpej Date: Wed, 9 Sep 1998 05:17:53 +0000 Subject: [PATCH] Don't use M_WAITOK to allocate the ring buffer; we could be in interrupt context. Reported by Lennart Augustsson. --- sys/dev/ic/com.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c index 38eb5d87a5d6..3a102ab7530c 100644 --- a/sys/dev/ic/com.c +++ b/sys/dev/ic/com.c @@ -1,4 +1,4 @@ -/* $NetBSD: com.c,v 1.146 1998/08/15 17:47:16 mycroft Exp $ */ +/* $NetBSD: com.c,v 1.147 1998/09/09 05:17:53 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -480,12 +480,18 @@ com_attach_subr(sc) tp->t_oproc = comstart; tp->t_param = comparam; tp->t_hwiflow = comhwiflow; - tty_attach(tp); sc->sc_tty = tp; - sc->sc_rbuf = malloc(com_rbuf_size << 1, M_DEVBUF, M_WAITOK); + sc->sc_rbuf = malloc(com_rbuf_size << 1, M_DEVBUF, M_NOWAIT); + if (sc->sc_rbuf == NULL) { + printf("%s: unable to allocate ring buffer\n", + sc->sc_dev.dv_xname); + return; + } sc->sc_ebuf = sc->sc_rbuf + (com_rbuf_size << 1); - + + tty_attach(tp); + if (!ISSET(sc->sc_hwflags, COM_HW_NOIEN)) SET(sc->sc_mcr, MCR_IENABLE); @@ -662,7 +668,8 @@ comopen(dev, flag, mode, p) if (unit >= com_cd.cd_ndevs) return (ENXIO); sc = com_cd.cd_devs[unit]; - if (sc == 0 || !ISSET(sc->sc_hwflags, COM_HW_DEV_OK)) + if (sc == 0 || !ISSET(sc->sc_hwflags, COM_HW_DEV_OK) || + sc->sc_rbuf == NULL) return (ENXIO); #ifdef KGDB