Linux-kernel mailing list archive 1999-20,: Re: [PATCH] ide_open is too permissive

# Re: [PATCH] ide_open is too permissive

Andries.Brouwer@cwi.nl
Mon, 17 May 1999 14:15:29 +0200 (MET DST)

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Pavel Machek: "Re: Capabilities done right [diff against 2.3.1]"
- Previous message: James Michael Keller: "Re: Suggestion for modules.."
- Maybe in reply to: Andries.Brouwer@cwi.nl: "[PATCH] ide_open is too permissive"

Ak, why am I so quick in responding?

> it looks like drive->usage was never decremented again in case
> the driver open failed.

Looking at the code I see that the open routine itself does
the decrement of drive->usage. Revised version:

--- /g1/linux/linux-2.3.2/linux/drivers/block/ide.c Sat May 15 21:10:22 1999
+++ ide.c Mon May 17 14:07:34 1999
@@ -1690,15 +1691,28 @@
while (drive->busy)
sleep_on(&drive->wqueue);
drive->usage++;
+ rc = 0;
if (drive->driver != NULL) {
- if ((rc = DRIVER(drive)->open(inode, filp, drive)))
+ if ((rc = DRIVER(drive)->open(inode, filp, drive))) {
MOD_DEC_USE_COUNT;
- return rc;
+ return rc;
+ }
+ } else {
+ printk ("%s: driver not present\n", drive->name);
+ rc = -ENXIO;
}
- printk ("%s: driver not present\n", drive->name);
- drive->usage--;
- MOD_DEC_USE_COUNT;
- return -ENXIO;
+
+ if (rc == 0 && drive->media == ide_disk) {
+ int minor = (MINOR(inode->i_rdev) & PARTN_MASK);
+ if (drive->part[minor].nr_sects == 0)
+ rc = -ENXIO;
+ }
+
+ if (rc) {
+ drive->usage--;
+ MOD_DEC_USE_COUNT;
+ }
+ return rc;
}
/*

Andries

-
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/

- Next message: Pavel Machek: "Re: Capabilities done right [diff against 2.3.1]"
- Previous message: James Michael Keller: "Re: Suggestion for modules.."
- Maybe in reply to: Andries.Brouwer@cwi.nl: "[PATCH] ide_open is too permissive"