Flaw in ide_unregister()
From: Richard Purdie (rpurdie_at_rpsys.net)
Date: 12/31/04
- Previous message: Paulo Marques: "Re: waiting 10s before mounting root filesystem?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: <linux-kernel@vger.kernel.org> Date: Fri, 31 Dec 2004 12:04:54 -0000
I've been having some problems with calls to ide_unregister() (in ide.c).
This function is declared void which should mean it always succeeds and yet
it can fail *silently* under the following condition:
if (drive->usage || DRIVER(drive)->busy) goto abort;
(it also fails if (!hwif->present) although that is not a problem)
The driver I've been having problems with is ide-cs.c. Specifically if a CF
card is removed without ejecting and unmounting the card first. In this
case, the hardware is gone so we want the ide_unregister call to succeed and
yet the above code aborts the unregister (silently). This makes it an ide
problem rather than an ide-cs/pcmcia problem.
There are several solutions:
1. Fix ide_unregister so it always succeeds. (Preferred Solution)
2. Add parameter to ide_unregister to state whether it should abort on
busy/usage or not. (ugly)
3. Add a return value. What does ide-cs.c do with it though? The hardware is
gone. (doesn't help)
Only a limited number of drivers use ide_unregister():
drivers/ide/ide-pnp.c
drivers/ide/arm/rapide.c
drivers/ide/legacy/ide-cs.c
drivers/macintosh/mediabay.c
Of these, I can't see anything that would break if we make ide_unregister
always succeed.
I've tried removing the if statement above and just letting ide_unregister
succeed but the call then just deadlocks. I had to make some small changes
to ide.c and ide-disk.c to stop it using interfaces we've marked as dead and
allow deregistration of dead devices.
The bare minimum of code I needed to make ide_unregister succeed when called
from ide-cs.c is in the following patch:
http://www.rpsys.net/openzaurus/ide.patch
There are probably other places checks are needed. I would appreciate it if
someone could comment on whether these changes can be made to the ide
drivers, what else may need to be done or if there is an alternative
solution I've overlooked.
Thanks,
Richard
-- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.298 / Virus Database: 265.6.7 - Release Date: 30/12/2004 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
- Previous message: Paulo Marques: "Re: waiting 10s before mounting root filesystem?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
- [PATCH 2.6.13-rc6] Fix handling in parport_pc init code
... thing is that module_init succeeds but something really bad had happened to ...
Also module_init does not fail if pnp_register_driverfails. ... parport_pc_find_isa_ports
(int autoirq, int autodma) ... send the line "unsubscribe linux-kernel" in ...
(Linux-Kernel) - [PATCH] Fix scripts/mkuboot.sh to return status
... If `mkimage` is either not found in search path or returns non-zero status, ...
`make uImage` succeeds when it should fail. ... to return status so build succeeds
or fails as appropriate. ... build failure when uImage target is not created. ...
(Linux-Kernel) - Re: -e fails sometimes
... would it sometimes fail and sometimes succeed? ... that it fails have a different
$file than the sometimes that it succeeds? ... do you know that the file did in fact exist
on disk at the exact instance ... (comp.lang.perl.misc) - Re: [PATCH] Fix scripts/mkuboot.sh to return status
... > `make uImage` succeeds when it should fail. ... > to return status
so build succeeds or fails as appropriate. ... send the line "unsubscribe linux-kernel"
in ... (Linux-Kernel) - Re: chdir/rmdir
... inode numbers to a pathname. ... And, even if __getcwdsucceeds, the ...
Note that system calls very rarely both fail and return a value - ... get back to the original
directory even if components of its pathname ... (freebsd-hackers)