diff options
author | Andrew Morton <akpm@osdl.org> | 2006-02-11 17:56:05 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-02-11 21:41:13 -0800 |
commit | 1d30883942cfe8a1e3f88f8b7f4c292aeba3db5a (patch) | |
tree | d53b73bb121b6b477ce64a6705d1a70f16581cb7 /drivers/char/tipar.c | |
parent | ef1bea9e2a5a72d2c3362522e0a09099406732ff (diff) | |
download | op-kernel-dev-1d30883942cfe8a1e3f88f8b7f4c292aeba3db5a.zip op-kernel-dev-1d30883942cfe8a1e3f88f8b7f4c292aeba3db5a.tar.gz |
[PATCH] tipar fixes
- tipar_open(): fix unsigned comparison
- tipar_open(): don't permit NULL pardevice (probably unneeded given the
above fix).
- tipar_init_module(): handle the situation where parport_register_driver()
failed to register any devices (parport_register_driver() drops the ->attach
return value on the floor).
This probably makes fixes #1 and #2 unneeded.
- tipar_init_module(): fix various error-path resource leaks.
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/tipar.c')
-rw-r--r-- | drivers/char/tipar.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/char/tipar.c b/drivers/char/tipar.c index 41a94bc..eb2eb3e 100644 --- a/drivers/char/tipar.c +++ b/drivers/char/tipar.c @@ -250,12 +250,17 @@ tipar_open(struct inode *inode, struct file *file) { unsigned int minor = iminor(inode) - TIPAR_MINOR; - if (minor > tp_count - 1) + if (tp_count == 0 || minor > tp_count - 1) return -ENXIO; if (test_and_set_bit(minor, &opened)) return -EBUSY; + if (!table[minor].dev) { + printk(KERN_ERR "%s: NULL device for minor %u\n", + __FUNCTION__, minor); + return -ENXIO; + } parport_claim_or_block(table[minor].dev); init_ti_parallel(minor); parport_release(table[minor].dev); @@ -510,16 +515,20 @@ tipar_init_module(void) err = PTR_ERR(tipar_class); goto out_chrdev; } - if (parport_register_driver(&tipar_driver)) { + if (parport_register_driver(&tipar_driver) || tp_count == 0) { printk(KERN_ERR "tipar: unable to register with parport\n"); err = -EIO; - goto out; + goto out_class; } err = 0; goto out; +out_class: + class_destroy(tipar_class); + out_chrdev: + devfs_remove("ticables/par"); unregister_chrdev(TIPAR_MAJOR, "tipar"); out: return err; |