kernel: xalloc error handling
This commit is contained in:
parent
861713765b
commit
9310f981b0
4 changed files with 33 additions and 13 deletions
|
@ -181,17 +181,25 @@ floppyreset(void)
|
|||
}
|
||||
|
||||
/*
|
||||
* Should check if this fails. Can do so
|
||||
* if there is no space <= 16MB for the DMA
|
||||
* Can fail if there is no space <= 16MB for the DMA
|
||||
* bounce buffer.
|
||||
*/
|
||||
dmainit(DMAchan, maxtsize);
|
||||
if(dmainit(DMAchan, maxtsize)){
|
||||
print("floppy: dmainit failed\n");
|
||||
fl.ndrive = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* allocate the drive storage
|
||||
*/
|
||||
fl.d = xalloc(fl.ndrive*sizeof(FDrive));
|
||||
fl.selected = fl.d;
|
||||
if(fl.d == nil){
|
||||
print("floppy: can't allocate memory\n");
|
||||
fl.ndrive = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* stop the motors
|
||||
|
|
|
@ -484,6 +484,10 @@ i82365probe(int x, int d, int dev)
|
|||
return 0; /* no revision number, not possible */
|
||||
|
||||
cp = xalloc(sizeof(I82365));
|
||||
if(cp == nil){
|
||||
print("i82365probe: out of memory\n");
|
||||
return 0;
|
||||
}
|
||||
cp->xreg = x;
|
||||
cp->dreg = d;
|
||||
cp->dev = dev;
|
||||
|
@ -611,12 +615,17 @@ devi82365link(void)
|
|||
if(ncontroller == 0)
|
||||
return;
|
||||
|
||||
_pcmspecial = pcmcia_pcmspecial;
|
||||
_pcmspecialclose = pcmcia_pcmspecialclose;
|
||||
|
||||
for(i = 0; i < ncontroller; i++)
|
||||
nslot += controller[i]->nslot;
|
||||
slot = xalloc(nslot * sizeof(PCMslot));
|
||||
if(slot == nil){
|
||||
print("i82365link: out of memory\n");
|
||||
nslot = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
_pcmspecial = pcmcia_pcmspecial;
|
||||
_pcmspecialclose = pcmcia_pcmspecialclose;
|
||||
|
||||
lastslot = slot;
|
||||
for(i = 0; i < ncontroller; i++){
|
||||
|
|
|
@ -87,7 +87,8 @@ mkbus(PCMPbus* p)
|
|||
if(buses[i] == 0)
|
||||
return 0;
|
||||
|
||||
bus = xalloc(sizeof(Bus));
|
||||
if((bus = xalloc(sizeof(Bus))) == nil)
|
||||
panic("mkbus: no memory for Bus");
|
||||
if(mpbus)
|
||||
mpbuslast->next = bus;
|
||||
else
|
||||
|
@ -210,7 +211,8 @@ mkiointr(PCMPintr* p)
|
|||
if((bus = mpgetbus(p->busno)) == 0)
|
||||
return 0;
|
||||
|
||||
aintr = xalloc(sizeof(Aintr));
|
||||
if((aintr = xalloc(sizeof(Aintr))) == nil)
|
||||
panic("iointr: no memory for Aintr");
|
||||
aintr->intr = p;
|
||||
|
||||
if(0)
|
||||
|
@ -224,8 +226,7 @@ mkiointr(PCMPintr* p)
|
|||
*/
|
||||
if(memcmp(mppcmp->product, "INTEL X38MLST ", 20) == 0){
|
||||
if(p->busno == 1 && p->intin == 16 && p->irq == 1){
|
||||
pcmpintr = malloc(sizeof(PCMPintr));
|
||||
if(pcmpintr == nil)
|
||||
if((pcmpintr = xalloc(sizeof(PCMPintr))) == nil)
|
||||
panic("iointr: no memory for PCMPintr");
|
||||
memmove(pcmpintr, p, sizeof(PCMPintr));
|
||||
print("mkiointr: %20.20s bus %d intin %d irq %d\n",
|
||||
|
@ -538,7 +539,7 @@ mpoverride(uchar** newp, uchar** e)
|
|||
|
||||
size = atoi(getconf("*mp"));
|
||||
if(size == 0) panic("mpoverride: invalid size in *mp");
|
||||
*newp = p = malloc(size);
|
||||
*newp = p = xalloc(size);
|
||||
if(p == nil) panic("mpoverride: can't allocate memory");
|
||||
*e = p + size;
|
||||
for(i = 0; ; i++){
|
||||
|
|
|
@ -40,7 +40,8 @@ intrenable(int irq, void (*f)(Ureg*, void*), void* a, int tbdf, char *name)
|
|||
return;
|
||||
}
|
||||
|
||||
v = xalloc(sizeof(Vctl));
|
||||
if((v = xalloc(sizeof(Vctl))) == nil)
|
||||
panic("intrenable: out of memory");
|
||||
v->isintr = 1;
|
||||
v->irq = irq;
|
||||
v->tbdf = tbdf;
|
||||
|
@ -147,7 +148,8 @@ trapenable(int vno, void (*f)(Ureg*, void*), void* a, char *name)
|
|||
|
||||
if(vno < 0 || vno >= VectorPIC)
|
||||
panic("trapenable: vno %d", vno);
|
||||
v = xalloc(sizeof(Vctl));
|
||||
if((v = xalloc(sizeof(Vctl))) == nil)
|
||||
panic("trapenable: out of memory");
|
||||
v->tbdf = BUSUNKNOWN;
|
||||
v->f = f;
|
||||
v->a = a;
|
||||
|
|
Loading…
Reference in a new issue