If the device goes away during ulpt_reset(), make sure not to call

ulpt_status() afterwards. This fixes a crash that can occur if a
USB printer is power-cycled when printing is just starting. The
problem is similar to that fixed in revision 1.33, but it is much
less likely to occur.

MFC after:	1 week
This commit is contained in:
iedowse 2003-06-15 11:55:50 +00:00
parent 6fb682520c
commit 08c9916461

View File

@ -528,8 +528,14 @@ ulptopen(dev_t dev, int flag, int mode, usb_proc_ptr p)
error = 0;
sc->sc_refcnt++;
if ((flags & ULPT_NOPRIME) == 0)
if ((flags & ULPT_NOPRIME) == 0) {
ulpt_reset(sc);
if (sc->sc_dying) {
error = ENXIO;
sc->sc_state = 0;
goto done;
}
}
for (spin = 0; (ulpt_status(sc) & LPS_SELECT) == 0; spin += STEP) {
DPRINTF(("ulpt_open: waiting a while\n"));