Commit 1d308839 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[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: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ef1bea9e
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment