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
This commit is contained in:
yar 2003-06-15 16:18:58 +00:00
parent 51aa556e27
commit 66f662a622
2 changed files with 8 additions and 0 deletions

View File

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

View File

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