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