ppdev: ppdev_init: do not return zero in case of failure
authorAlexey Khoroshilov <khoroshilov@ispras.ru>
Sat, 1 Sep 2012 20:31:58 +0000 (00:31 +0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Sep 2012 20:44:04 +0000 (13:44 -0700)
Error handling of parport_register_driver() in ppdev_init()
is broken because it deallocates all resources but still
returns zero.

Currently parport_register_driver() always succeeds.
Nevertheless it is worth to fix the issue.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/ppdev.c

index 3fcf80ff12f2226fce01f5749e96972d3857072b..d0d824ebf2c187d492f29daef8bbf1043f56d7f1 100644 (file)
@@ -783,7 +783,8 @@ static int __init ppdev_init (void)
                err = PTR_ERR(ppdev_class);
                goto out_chrdev;
        }
-       if (parport_register_driver(&pp_driver)) {
+       err = parport_register_driver(&pp_driver);
+       if (err < 0) {
                printk (KERN_WARNING CHRDEV ": unable to register with parport\n");
                goto out_class;
        }