kernel: add extra negative and power-of-two check to pcibarsize()
This commit is contained in:
parent
2a531d444c
commit
78c7ad88ff
1 changed files with 5 additions and 5 deletions
|
@ -190,16 +190,16 @@ pcibarsize(Pcidev *p, int rno)
|
||||||
pcicfgrw32(p->tbdf, rno, v, 0);
|
pcicfgrw32(p->tbdf, rno, v, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
size = -size;
|
||||||
|
|
||||||
iunlock(&pcicfglock);
|
iunlock(&pcicfglock);
|
||||||
|
|
||||||
if(size > 0){
|
if(size < 0 || (size & size-1) != 0){
|
||||||
print("pcibarsize: %T invalid bar rno %x mask %llux\n",
|
print("pcibarsize: %T invalid bar rno %#x size %#llux mask %#llux\n",
|
||||||
p->tbdf, rno, (uvlong)size);
|
p->tbdf, rno, size, -size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
return size;
|
||||||
return -size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue