diff options
Diffstat (limited to 'sys/dev/sio/sio.c')
-rw-r--r-- | sys/dev/sio/sio.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c index e2c8dda..95b8bfeb 100644 --- a/sys/dev/sio/sio.c +++ b/sys/dev/sio/sio.c @@ -442,7 +442,7 @@ sysctl_machdep_comdefaultrate SYSCTL_HANDLER_ARGS return (0); com = com_addr(comconsole); - if (!com) + if (com == NULL) return (ENXIO); /* @@ -510,11 +510,11 @@ sio_pccard_detach(dev) struct com_s *com; com = (struct com_s *) device_get_softc(dev); - if (!com) { + if (com == NULL) { device_printf(dev, "NULL com in siounload\n"); return (0); } - if (!com->iobase) { + if (com->iobase == 0) { device_printf(dev, "already unloaded!\n"); return (0); } @@ -526,17 +526,16 @@ sio_pccard_detach(dev) if (com->ioportres) bus_release_resource(dev, SYS_RES_IOPORT, 0, com->ioportres); if (com->tp && (com->tp->t_state & TS_ISOPEN)) { - device_printf(dev, "unload\n"); + device_printf(dev, "still open, forcing close\n"); com->tp->t_gen++; ttyclose(com->tp); ttwakeup(com->tp); ttwwakeup(com->tp); - device_printf(dev, "Was busy, so crash likely\n"); } else { if (com->ibuf != NULL) free(com->ibuf, M_DEVBUF); - device_printf(dev, "unload, gone\n"); } + device_printf(dev, "unloaded\n"); return (0); } #endif /* NCARD > 0 */ @@ -642,7 +641,7 @@ sioprobe(dev) port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, IO_COMSIZE, RF_ACTIVE); if (!port) - return ENXIO; + return (ENXIO); #if 0 /* @@ -989,7 +988,7 @@ sioattach(dev) port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, IO_COMSIZE, RF_ACTIVE); if (!port) - return ENXIO; + return (ENXIO); iobase = rman_get_start(port); unit = device_get_unit(dev); @@ -1425,6 +1424,8 @@ sioclose(dev, flag, mode, p) if (mynor & CONTROL_MASK) return (0); com = com_addr(MINOR_TO_UNIT(mynor)); + if (com == NULL) + return (ENODEV); tp = com->tp; s = spltty(); (*linesw[tp->t_line].l_close)(tp, flag); @@ -1512,7 +1513,7 @@ sioread(dev, uio, flag) if (mynor & CONTROL_MASK) return (ENODEV); com = com_addr(MINOR_TO_UNIT(mynor)); - if (com->gone) + if (com == NULL || com->gone) return (ENODEV); return ((*linesw[com->tp->t_line].l_read)(com->tp, uio, flag)); } @@ -1533,7 +1534,7 @@ siowrite(dev, uio, flag) unit = MINOR_TO_UNIT(mynor); com = com_addr(unit); - if (com->gone) + if (com == NULL || com->gone) return (ENODEV); /* * (XXX) We disallow virtual consoles if the physical console is @@ -1923,7 +1924,7 @@ sioioctl(dev, cmd, data, flag, p) mynor = minor(dev); com = com_addr(MINOR_TO_UNIT(mynor)); - if (com->gone) + if (com == NULL || com->gone) return (ENODEV); iobase = com->iobase; if (mynor & CONTROL_MASK) { @@ -2159,6 +2160,8 @@ comparam(tp, t) /* parameters are OK, convert them to the com struct and the device */ unit = DEV_TO_UNIT(tp->t_dev); com = com_addr(unit); + if (com == NULL) + return (ENODEV); iobase = com->iobase; s = spltty(); if (divisor == 0) @@ -2392,6 +2395,8 @@ comstart(tp) unit = DEV_TO_UNIT(tp->t_dev); com = com_addr(unit); + if (com == NULL) + return; s = spltty(); disable_intr(); if (tp->t_state & TS_TTSTOP) @@ -2474,7 +2479,7 @@ comstop(tp, rw) struct com_s *com; com = com_addr(DEV_TO_UNIT(tp->t_dev)); - if (com->gone) + if (com == NULL || com->gone) return; disable_intr(); if (rw & FWRITE) { |