kernel: add extra negative and power-of-two check to pcibarsize()

This commit is contained in:
cinap_lenrek 2021-11-26 21:47:15 +00:00
parent 2a531d444c
commit 78c7ad88ff

View file

@ -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