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 13:58:59 +0200 (MET DST)

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Gregory Maxwell: "Re: Deletion of big files..."
- Previous message: Alexander Viro: "Re: VFAT rename"
- Maybe in reply to: Andries.Brouwer@cwi.nl: "[PATCH] ide_open is too permissive"
- Next in thread: Andries.Brouwer@cwi.nl: "Re: [PATCH] ide_open is too permissive"

From gadio@netvision.net.il Mon May 17 07:28:58 1999

We should move the test a bit down, after the request_module() attempts.

Yes, I also thought of that and promised Andre a new version.
Let me make it right away.

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

Your line numbers may differ, I have other changes here as well.
This is the same four lines as before, but moving the code down
forces me to handle drive->usage and MOD_DEC_USE_COUNT.
By the way, if I am not mistaken this now fixes a bug in the old code:
it looks like drive->usage was never decremented again in case
the driver open failed.

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: Gregory Maxwell: "Re: Deletion of big files..."
- Previous message: Alexander Viro: "Re: VFAT rename"
- Maybe in reply to: Andries.Brouwer@cwi.nl: "[PATCH] ide_open is too permissive"
- Next in thread: Andries.Brouwer@cwi.nl: "Re: [PATCH] ide_open is too permissive"