diff options
author | ru <ru@FreeBSD.org> | 2006-10-06 14:31:32 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2006-10-06 14:31:32 +0000 |
commit | c29a0764f4cb1ad589b35261acae5f31a5bae9b3 (patch) | |
tree | 8d9646f068ef56d1f34de2ab4e79b7d87092d6b2 /sys/dev/pci/pci_user.c | |
parent | d75fd1fec60649ada2e782efe9dce45225eea704 (diff) | |
download | FreeBSD-src-c29a0764f4cb1ad589b35261acae5f31a5bae9b3.zip FreeBSD-src-c29a0764f4cb1ad589b35261acae5f31a5bae9b3.tar.gz |
Actually make bounds checking for PCIOCREAD and PCIOCWRITE work.
Diffstat (limited to 'sys/dev/pci/pci_user.c')
-rw-r--r-- | sys/dev/pci/pci_user.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/dev/pci/pci_user.c b/sys/dev/pci/pci_user.c index 6122ba5..469dc40 100644 --- a/sys/dev/pci/pci_user.c +++ b/sys/dev/pci/pci_user.c @@ -374,12 +374,14 @@ getconfexit: case 4: case 2: case 1: - /* make sure register is in bounds and aligned */ - if (cmd == PCIOCREAD || cmd == PCIOCWRITE) - if (io->pi_reg < 0 || - io->pi_reg + io->pi_width > PCI_REGMAX || - io->pi_reg & (io->pi_width - 1)) - error = EINVAL; + /* Make sure register is in bounds and aligned. */ + if ((cmd == PCIOCREAD || cmd == PCIOCWRITE) && + (io->pi_reg < 0 || + io->pi_reg + io->pi_width > PCI_REGMAX + 1 || + io->pi_reg & (io->pi_width - 1))) { + error = EINVAL; + break; + } /* * Assume that the user-level bus number is * in fact the physical PCI bus number. |