diff options
author | yar <yar@FreeBSD.org> | 2003-06-15 16:18:58 +0000 |
---|---|---|
committer | yar <yar@FreeBSD.org> | 2003-06-15 16:18:58 +0000 |
commit | 66f662a622976cb236f15dc6c2767c396daa7c1d (patch) | |
tree | 9b247ad85f6cc3a24ebbe7a8cbda9441fb14aadd | |
parent | 51aa556e270fbb206f8f6dcb0700585c15baefb5 (diff) | |
download | FreeBSD-src-66f662a622976cb236f15dc6c2767c396daa7c1d.zip FreeBSD-src-66f662a622976cb236f15dc6c2767c396daa7c1d.tar.gz |
Check whether the floppy type pointer has been set before trying
to access floppy parameters through it.
Note: The DIOCGSECTORSIZE and DIOCGMEDIASIZE handlers withing
fdioctl() couldn't be just moved to below the existing check
for blocking mode because fd->ft can be non-NULL while still
in non-blocking mode (fd->ft can be set with the FD_STYPE ioctl.)
PR: kern/52338
No MFC: Not applicable to STABLE
-rw-r--r-- | sys/dev/fdc/fdc.c | 4 | ||||
-rw-r--r-- | sys/isa/fd.c | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c index f4068ef..b6ec2c3 100644 --- a/sys/dev/fdc/fdc.c +++ b/sys/dev/fdc/fdc.c @@ -2622,10 +2622,14 @@ fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) switch (cmd) { case DIOCGMEDIASIZE: + if (fd->ft == 0) + return ((fd->flags & FD_NONBLOCK) ? EAGAIN : ENXIO); *(off_t *)addr = (128 << (fd->ft->secsize)) * fd->ft->size; return (0); case DIOCGSECTORSIZE: + if (fd->ft == 0) + return ((fd->flags & FD_NONBLOCK) ? EAGAIN : ENXIO); *(u_int *)addr = 128 << (fd->ft->secsize); return (0); diff --git a/sys/isa/fd.c b/sys/isa/fd.c index f4068ef..b6ec2c3 100644 --- a/sys/isa/fd.c +++ b/sys/isa/fd.c @@ -2622,10 +2622,14 @@ fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) switch (cmd) { case DIOCGMEDIASIZE: + if (fd->ft == 0) + return ((fd->flags & FD_NONBLOCK) ? EAGAIN : ENXIO); *(off_t *)addr = (128 << (fd->ft->secsize)) * fd->ft->size; return (0); case DIOCGSECTORSIZE: + if (fd->ft == 0) + return ((fd->flags & FD_NONBLOCK) ? EAGAIN : ENXIO); *(u_int *)addr = 128 << (fd->ft->secsize); return (0); |