diff options
author | bz <bz@FreeBSD.org> | 2008-04-20 17:45:32 +0000 |
---|---|---|
committer | bz <bz@FreeBSD.org> | 2008-04-20 17:45:32 +0000 |
commit | 24c28f2576c965815722f35795655a5199016a4e (patch) | |
tree | 9e52d23618deed966ecaed66a383a8e8cd6ed566 /sys/dev/ata | |
parent | 5f68582c91dbb40be442924d023c768140e47446 (diff) | |
download | FreeBSD-src-24c28f2576c965815722f35795655a5199016a4e.zip FreeBSD-src-24c28f2576c965815722f35795655a5199016a4e.tar.gz |
devclass_get_maxunit() returns n+1 with n starting at 0.
So if we have channel 0..3 devclass_get_maxunit is 4.
It's never been a problem as devclass_get_device() has
catched a possibly bad input.
Discussed with: scottl
Diffstat (limited to 'sys/dev/ata')
-rw-r--r-- | sys/dev/ata/ata-all.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c index 597bb38..83da7ff 100644 --- a/sys/dev/ata/ata-all.c +++ b/sys/dev/ata/ata-all.c @@ -366,12 +366,13 @@ ata_ioctl(struct cdev *dev, u_long cmd, caddr_t data, switch (cmd) { case IOCATAGMAXCHANNEL: + /* In case we have channel 0..n this will return n+1. */ *value = devclass_get_maxunit(ata_devclass); error = 0; break; case IOCATAREINIT: - if (*value > devclass_get_maxunit(ata_devclass) || + if (*value >= devclass_get_maxunit(ata_devclass) || !(device = devclass_get_device(ata_devclass, *value))) return ENXIO; error = ata_reinit(device); @@ -379,7 +380,7 @@ ata_ioctl(struct cdev *dev, u_long cmd, caddr_t data, break; case IOCATAATTACH: - if (*value > devclass_get_maxunit(ata_devclass) || + if (*value >= devclass_get_maxunit(ata_devclass) || !(device = devclass_get_device(ata_devclass, *value))) return ENXIO; /* XXX SOS should enable channel HW on controller */ @@ -387,7 +388,7 @@ ata_ioctl(struct cdev *dev, u_long cmd, caddr_t data, break; case IOCATADETACH: - if (*value > devclass_get_maxunit(ata_devclass) || + if (*value >= devclass_get_maxunit(ata_devclass) || !(device = devclass_get_device(ata_devclass, *value))) return ENXIO; error = ata_detach(device); @@ -395,7 +396,7 @@ ata_ioctl(struct cdev *dev, u_long cmd, caddr_t data, break; case IOCATADEVICES: - if (devices->channel > devclass_get_maxunit(ata_devclass) || + if (devices->channel >= devclass_get_maxunit(ata_devclass) || !(device = devclass_get_device(ata_devclass, devices->channel))) return ENXIO; bzero(devices->name[0], 32); |