Messages in this thread | | | Date | Mon, 17 May 1999 08:30:10 +0300 (IDT) | From | Gadi Oxman <> | Subject | Re: [PATCH] ide_open is too permissive |
| |
Hi,
We should move the test a bit down, after the request_module() attempts. Otherwise, when using modules in combination with kmod, on the first open() the check will return ENXIO unconditionally rather than loading the IDE disk driver, as nr_sectors will be 0 since the ide-disk module was not initialized yet.
Gadi
On Sun, 16 May 1999 Andries.Brouwer@cwi.nl wrote:
> The SCSI code (sd_open) returns -ENXIO if one tries to open > a nonexistent partition of an exiting disk. Good. > But the IDE code just succeeds in the corresponding > situation. This means that attempts to mount a nonexistent > partition yield nonsense like > > May 16 14:20:03 nata kernel: 03:0c: rw=0, want=1, limit=0 > May 16 14:20:03 nata kernel: attempt to access beyond end of device > May 16 14:20:03 nata kernel: hda<: bad access: block=0, count=1 > May 16 14:20:03 nata kernel: end_request: I/O error, dev 03:0c (hda), sector 0 > > in the syslog. The patch below makes ide_open fail in this situation. > (Maybe the surrounding `if (drive->media == ide_disk)' is too > cautious - I have not thought about what other IDE devices there > are, and what meaning the minor could have for them.) > > Andries > > > --- ide.c~ Sat May 15 21:13:29 1999 > +++ ide.c Sun May 16 14:37:23 1999 > @@ -1672,7 +1672,12 @@ > int rc; > > if ((drive = get_info_ptr(inode->i_rdev)) == NULL) > - return -ENXIO; > + return -ENXIO; /* no such drive */ > + if (drive->media == ide_disk) { > + int minor = (MINOR(inode->i_rdev) & PARTN_MASK); > + if (drive->part[minor].nr_sects == 0) > + return -ENXIO; /* no such partition */ > + } > MOD_INC_USE_COUNT; > if (drive->driver == NULL) > ide_init_module(IDE_DRIVER_MODULE); > > - > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.rutgers.edu > Please read the FAQ at http://www.tux.org/lkml/ > >
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |