diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2021-11-26 21:47:15 +0000 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2021-11-26 21:47:15 +0000 |
commit | 78c7ad88ffbfbd2b7a7269d863e5f4be7535b566 (patch) | |
tree | 781971f7bf7d25b5e778bdf2b6aeb9fe8ba2aef9 | |
parent | 2a531d444cf53419e8d4af716b9937d14ca5b08c (diff) |
kernel: add extra negative and power-of-two check to pcibarsize()
-rw-r--r-- | sys/src/9/port/pci.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/src/9/port/pci.c b/sys/src/9/port/pci.c index a6fa3abfa..5ca42d5ac 100644 --- a/sys/src/9/port/pci.c +++ b/sys/src/9/port/pci.c @@ -190,16 +190,16 @@ pcibarsize(Pcidev *p, int rno) pcicfgrw32(p->tbdf, rno, v, 0); } } + size = -size; iunlock(&pcicfglock); - if(size > 0){ - print("pcibarsize: %T invalid bar rno %x mask %llux\n", - p->tbdf, rno, (uvlong)size); + if(size < 0 || (size & size-1) != 0){ + print("pcibarsize: %T invalid bar rno %#x size %#llux mask %#llux\n", + p->tbdf, rno, size, -size); return 0; } - - return -size; + return size; } void |