Add checks for contigmalloc(9) failure.

This commit is contained in:
Pyun YongHyeon 2007-06-12 04:30:30 +00:00
parent 1c88901672
commit 8b1568ff6e

View File

@ -264,6 +264,11 @@ txp_attach(dev)
sc->sc_fwbuf = contigmalloc(32768, M_DEVBUF,
M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0);
if (sc->sc_fwbuf == NULL) {
device_printf(dev, "no memory for firmware\n");
error = ENXIO;
goto fail;
}
error = txp_download_fw(sc);
contigfree(sc->sc_fwbuf, 32768, M_DEVBUF);
sc->sc_fwbuf = NULL;
@ -273,6 +278,11 @@ txp_attach(dev)
sc->sc_ldata = contigmalloc(sizeof(struct txp_ldata), M_DEVBUF,
M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0);
if (sc->sc_ldata == NULL) {
device_printf(dev, "no memory for descriptor ring\n");
error = ENXIO;
goto fail;
}
bzero(sc->sc_ldata, sizeof(struct txp_ldata));
if (txp_alloc_rings(sc)) {