deal with failed malloc calls

Noticed by:	Coverity Prevent analysis tool
Glanced at by:	mdodd
This commit is contained in:
Sam Leffler 2005-03-26 21:30:49 +00:00
parent 9bb329f4e5
commit 4204b6b9a0

View File

@ -266,13 +266,27 @@ void pccard_check_cis_quirks(device_t dev)
if (pf_last == q->pf) {
cfe = malloc(sizeof(*cfe), M_DEVBUF, M_NOWAIT);
if (cfe == NULL) {
device_printf(dev, "no memory for quirk (1)\n");
continue;
}
*cfe = *q->cfe;
STAILQ_INSERT_TAIL(&pf->cfe_head, cfe, cfe_list);
} else {
pf = malloc(sizeof(*pf), M_DEVBUF, M_NOWAIT);
if (pf == NULL) {
device_printf(dev,
"no memory for pccard function\n");
continue;
}
*pf = *q->pf;
STAILQ_INIT(&pf->cfe_head);
cfe = malloc(sizeof(*cfe), M_DEVBUF, M_NOWAIT);
if (cfe == NULL) {
free(pf, M_DEVBUF);
device_printf(dev, "no memory for quirk (2)\n");
continue;
}
*cfe = *q->cfe;
STAILQ_INSERT_TAIL(&pf->cfe_head, cfe, cfe_list);
STAILQ_INSERT_TAIL(&sc->card.pf_head, pf, pf_list);