1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-17 10:26:15 +00:00

Check for NULL on resource allocation. For the moment, punt, but we should

be smarter about a) cleanup and b) fallback.
This commit is contained in:
Warner Losh 2002-03-07 00:05:26 +00:00
parent 9db35c8cc3
commit 8e635fb764
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=91770

View File

@ -663,6 +663,11 @@ cardbus_alloc_resources(device_t cbdev, device_t child)
res = bus_alloc_resource(cbdev, SYS_RES_MEMORY, &rid, 0,
(dinfo->mprefetchable & dinfo->mbelow1mb)?0xFFFFF:~0UL,
mem_psize, flags);
if (res == NULL) { /* XXX need cleanup*/
device_printf(cbdev, "Unable to allocate memory for "
"prefetchable memory.\n");
return ENOMEM;
}
start = rman_get_start(res);
end = rman_get_end(res);
DEVPRINTF((cbdev, "Prefetchable memory at %x-%x\n", start, end));
@ -730,6 +735,11 @@ cardbus_alloc_resources(device_t cbdev, device_t child)
res = bus_alloc_resource(cbdev, SYS_RES_MEMORY, &rid, 0,
((~dinfo->mprefetchable) & dinfo->mbelow1mb)?0xFFFFF:~0UL,
mem_nsize, flags);
if (res == NULL) { /* XXX need cleanup*/
device_printf(cbdev, "Unable to allocate memory for "
"non-prefetchable memory.\n");
return ENOMEM;
}
start = rman_get_start(res);
end = rman_get_end(res);
DEVPRINTF((cbdev, "Non-prefetchable memory at %x-%x\n",
@ -790,6 +800,10 @@ cardbus_alloc_resources(device_t cbdev, device_t child)
rid = 0;
res = bus_alloc_resource(cbdev, SYS_RES_IOPORT, &rid, 0, ~0UL,
io_size, flags);
if (res == NULL) { /* XXX need cleanup*/
device_printf(cbdev, "Unable to allocate I/O ports\n");
return ENOMEM;
}
start = rman_get_start(res);
end = rman_get_end(res);
DEVPRINTF((cbdev, "IO port at %x-%x\n", start, end));
@ -832,6 +846,10 @@ cardbus_alloc_resources(device_t cbdev, device_t child)
rid = 0;
res = bus_alloc_resource(cbdev, SYS_RES_IRQ, &rid, 0, ~0UL, 1,
RF_SHAREABLE);
if (res == NULL) { /* XXX need cleanup*/
device_printf(cbdev, "Unable to allocate IRQ\n");
return ENOMEM;
}
resource_list_add(&dinfo->pci.resources, SYS_RES_IRQ, rid,
rman_get_start(res), rman_get_end(res), 1);
dinfo->pci.cfg.intline = rman_get_start(res);