aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2006-02-11 20:56:05 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-02-12 00:41:13 -0500
commit1d30883942cfe8a1e3f88f8b7f4c292aeba3db5a (patch)
treed53b73bb121b6b477ce64a6705d1a70f16581cb7
parentef1bea9e2a5a72d2c3362522e0a09099406732ff (diff)
[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>
-rw-r--r--drivers/char/tipar.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/char/tipar.c b/drivers/char/tipar.c
index 41a94bc79f67..eb2eb3e12d6a 100644
--- a/drivers/char/tipar.c
+++ b/drivers/char/tipar.c
@@ -250,12 +250,17 @@ tipar_open(struct inode *inode, struct file *file)
250{ 250{
251 unsigned int minor = iminor(inode) - TIPAR_MINOR; 251 unsigned int minor = iminor(inode) - TIPAR_MINOR;
252 252
253 if (minor > tp_count - 1) 253 if (tp_count == 0 || minor > tp_count - 1)
254 return -ENXIO; 254 return -ENXIO;
255 255
256 if (test_and_set_bit(minor, &opened)) 256 if (test_and_set_bit(minor, &opened))
257 return -EBUSY; 257 return -EBUSY;
258 258
259 if (!table[minor].dev) {
260 printk(KERN_ERR "%s: NULL device for minor %u\n",
261 __FUNCTION__, minor);
262 return -ENXIO;
263 }
259 parport_claim_or_block(table[minor].dev); 264 parport_claim_or_block(table[minor].dev);
260 init_ti_parallel(minor); 265 init_ti_parallel(minor);
261 parport_release(table[minor].dev); 266 parport_release(table[minor].dev);
@@ -510,16 +515,20 @@ tipar_init_module(void)
510 err = PTR_ERR(tipar_class); 515 err = PTR_ERR(tipar_class);
511 goto out_chrdev; 516 goto out_chrdev;
512 } 517 }
513 if (parport_register_driver(&tipar_driver)) { 518 if (parport_register_driver(&tipar_driver) || tp_count == 0) {
514 printk(KERN_ERR "tipar: unable to register with parport\n"); 519 printk(KERN_ERR "tipar: unable to register with parport\n");
515 err = -EIO; 520 err = -EIO;
516 goto out; 521 goto out_class;
517 } 522 }
518 523
519 err = 0; 524 err = 0;
520 goto out; 525 goto out;
521 526
527out_class:
528 class_destroy(tipar_class);
529
522out_chrdev: 530out_chrdev:
531 devfs_remove("ticables/par");
523 unregister_chrdev(TIPAR_MAJOR, "tipar"); 532 unregister_chrdev(TIPAR_MAJOR, "tipar");
524out: 533out:
525 return err; 534 return err;