From f14e0e786850404c04f1d9fe21e576f27db95a47 Mon Sep 17 00:00:00 2001 From: jsg Date: Fri, 22 May 2015 12:52:00 +0000 Subject: [PATCH] Don't use an uninitialised softc pointer in midiread/midiwrite. ok ratchov@ --- sys/dev/midi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/dev/midi.c b/sys/dev/midi.c index 16235f24225..709368f0c95 100644 --- a/sys/dev/midi.c +++ b/sys/dev/midi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: midi.c,v 1.39 2015/05/16 09:56:10 ratchov Exp $ */ +/* $OpenBSD: midi.c,v 1.40 2015/05/22 12:52:00 jsg Exp $ */ /* * Copyright (c) 2003, 2004 Alexandre Ratchov @@ -107,7 +107,7 @@ int midiread(dev_t dev, struct uio *uio, int ioflag) { struct midi_softc *sc; - struct midi_buffer *mb = &sc->inbuf; + struct midi_buffer *mb; size_t count; int error; @@ -118,6 +118,7 @@ midiread(dev_t dev, struct uio *uio, int ioflag) error = ENXIO; goto done; } + mb = &sc->inbuf; /* if there is no data then sleep (unless IO_NDELAY flag is set) */ error = 0; @@ -240,7 +241,7 @@ int midiwrite(dev_t dev, struct uio *uio, int ioflag) { struct midi_softc *sc; - struct midi_buffer *mb = &sc->outbuf; + struct midi_buffer *mb; size_t count; int error; @@ -251,6 +252,7 @@ midiwrite(dev_t dev, struct uio *uio, int ioflag) error = ENXIO; goto done; } + mb = &sc->outbuf; /* * If IO_NDELAY flag is set then check if there is enough room -- 2.20.1