Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[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>

authored by

Andrew Morton and committed by
Linus Torvalds
1d308839 ef1bea9e

+12 -3
+12 -3
drivers/char/tipar.c
··· 250 250 { 251 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 254 return -ENXIO; 255 255 256 256 if (test_and_set_bit(minor, &opened)) 257 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 264 parport_claim_or_block(table[minor].dev); 260 265 init_ti_parallel(minor); 261 266 parport_release(table[minor].dev); ··· 515 510 err = PTR_ERR(tipar_class); 516 511 goto out_chrdev; 517 512 } 518 - if (parport_register_driver(&tipar_driver)) { 513 + if (parport_register_driver(&tipar_driver) || tp_count == 0) { 519 514 printk(KERN_ERR "tipar: unable to register with parport\n"); 520 515 err = -EIO; 521 - goto out; 516 + goto out_class; 522 517 } 523 518 524 519 err = 0; 525 520 goto out; 526 521 522 + out_class: 523 + class_destroy(tipar_class); 524 + 527 525 out_chrdev: 526 + devfs_remove("ticables/par"); 528 527 unregister_chrdev(TIPAR_MAJOR, "tipar"); 529 528 out: 530 529 return err;