[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>
This commit is contained in:
parent
ef1bea9e2a
commit
1d30883942
@ -250,12 +250,17 @@ tipar_open(struct inode *inode, struct file *file)
|
|||||||
{
|
{
|
||||||
unsigned int minor = iminor(inode) - TIPAR_MINOR;
|
unsigned int minor = iminor(inode) - TIPAR_MINOR;
|
||||||
|
|
||||||
if (minor > tp_count - 1)
|
if (tp_count == 0 || minor > tp_count - 1)
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
||||||
if (test_and_set_bit(minor, &opened))
|
if (test_and_set_bit(minor, &opened))
|
||||||
return -EBUSY;
|
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);
|
parport_claim_or_block(table[minor].dev);
|
||||||
init_ti_parallel(minor);
|
init_ti_parallel(minor);
|
||||||
parport_release(table[minor].dev);
|
parport_release(table[minor].dev);
|
||||||
@ -510,16 +515,20 @@ tipar_init_module(void)
|
|||||||
err = PTR_ERR(tipar_class);
|
err = PTR_ERR(tipar_class);
|
||||||
goto out_chrdev;
|
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");
|
printk(KERN_ERR "tipar: unable to register with parport\n");
|
||||||
err = -EIO;
|
err = -EIO;
|
||||||
goto out;
|
goto out_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = 0;
|
err = 0;
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
out_class:
|
||||||
|
class_destroy(tipar_class);
|
||||||
|
|
||||||
out_chrdev:
|
out_chrdev:
|
||||||
|
devfs_remove("ticables/par");
|
||||||
unregister_chrdev(TIPAR_MAJOR, "tipar");
|
unregister_chrdev(TIPAR_MAJOR, "tipar");
|
||||||
out:
|
out:
|
||||||
return err;
|
return err;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user