Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ir Be a little more paranoid.



details:   https://anonhg.NetBSD.org/src/rev/800140c4656c
branches:  trunk
changeset: 519766:800140c4656c
user:      augustss <augustss%NetBSD.org@localhost>
date:      Wed Dec 26 10:56:58 2001 +0000

description:
Be a little more paranoid.

diffstat:

 sys/dev/ir/irframe.c     |  12 ++++++------
 sys/dev/ir/irframe_tty.c |   4 +++-
 2 files changed, 9 insertions(+), 7 deletions(-)

diffs (76 lines):

diff -r 1748c7124264 -r 800140c4656c sys/dev/ir/irframe.c
--- a/sys/dev/ir/irframe.c      Wed Dec 26 10:54:56 2001 +0000
+++ b/sys/dev/ir/irframe.c      Wed Dec 26 10:56:58 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: irframe.c,v 1.13 2001/12/14 12:57:30 augustss Exp $    */
+/*     $NetBSD: irframe.c,v 1.14 2001/12/26 10:56:58 augustss Exp $    */
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -209,11 +209,11 @@
        sc = device_lookup(&irframe_cd, IRFRAMEUNIT(dev));
        if (sc == NULL)
                return (ENXIO);
+       sc->sc_open = 0;
        if (sc->sc_methods->im_close != NULL)
                error = sc->sc_methods->im_close(sc->sc_handle, flag, mode, p);
        else
                error = 0;
-       sc->sc_open = 0;
        return (error);
 }
 
@@ -225,7 +225,7 @@
        sc = device_lookup(&irframe_cd, IRFRAMEUNIT(dev));
        if (sc == NULL)
                return (ENXIO);
-       if ((sc->sc_dev.dv_flags & DVF_ACTIVE) == 0)
+       if ((sc->sc_dev.dv_flags & DVF_ACTIVE) == 0 || !sc->sc_open)
                return (EIO);
        if (uio->uio_resid < sc->sc_params.maxsize) {
 #ifdef DIAGNOSTIC
@@ -245,7 +245,7 @@
        sc = device_lookup(&irframe_cd, IRFRAMEUNIT(dev));
        if (sc == NULL)
                return (ENXIO);
-       if ((sc->sc_dev.dv_flags & DVF_ACTIVE) == 0)
+       if ((sc->sc_dev.dv_flags & DVF_ACTIVE) == 0 || !sc->sc_open)
                return (EIO);
        if (uio->uio_resid > sc->sc_params.maxsize) {
 #ifdef DIAGNOSTIC
@@ -338,7 +338,7 @@
        sc = device_lookup(&irframe_cd, IRFRAMEUNIT(dev));
        if (sc == NULL)
                return (ENXIO);
-       if ((sc->sc_dev.dv_flags & DVF_ACTIVE) == 0)
+       if ((sc->sc_dev.dv_flags & DVF_ACTIVE) == 0 || !sc->sc_open)
                return (EIO);
 
        switch (cmd) {
@@ -378,7 +378,7 @@
        sc = device_lookup(&irframe_cd, IRFRAMEUNIT(dev));
        if (sc == NULL)
                return (ENXIO);
-       if ((sc->sc_dev.dv_flags & DVF_ACTIVE) == 0)
+       if ((sc->sc_dev.dv_flags & DVF_ACTIVE) == 0 || !sc->sc_open)
                return (EIO);
 
        return (sc->sc_methods->im_poll(sc->sc_handle, events, p));
diff -r 1748c7124264 -r 800140c4656c sys/dev/ir/irframe_tty.c
--- a/sys/dev/ir/irframe_tty.c  Wed Dec 26 10:54:56 2001 +0000
+++ b/sys/dev/ir/irframe_tty.c  Wed Dec 26 10:56:58 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: irframe_tty.c,v 1.18 2001/12/20 11:30:13 augustss Exp $        */
+/*     $NetBSD: irframe_tty.c,v 1.19 2001/12/26 10:56:58 augustss Exp $        */
 
 /*
  * TODO
@@ -337,6 +337,8 @@
        DPRINTF(("%s: nframe=%d framei=%d frameo=%d\n",
                 __FUNCTION__, sc->sc_nframes, sc->sc_framei, sc->sc_frameo));
 
+       if (sc->sc_inbuf == NULL) /* XXX happens if device is closed? */
+               return;
        if (sc->sc_nframes >= MAXFRAMES) {
 #ifdef IRFRAMET_DEBUG
                printf("%s: dropped frame\n", __FUNCTION__);



Home | Main Index | Thread Index | Old Index