parport: fix error handling
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>
Mon, 15 Jun 2015 14:35:49 +0000 (20:05 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 23 Jul 2015 04:15:49 +0000 (21:15 -0700)
After registering the device if exclusive access fails for any reason
then we need to unregister the device to remove all references.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/parport/share.c

index 8067f54ce050a6c8cf3a4c18d9b4ea560f017d94..d8079e37a60622dc11a498bbfb2b5508db3431b2 100644 (file)
@@ -907,7 +907,8 @@ parport_register_dev_model(struct parport *port, const char *name,
                        spin_unlock(&port->physport->pardevice_lock);
                        pr_debug("%s: cannot grant exclusive access for device %s\n",
                                 port->name, name);
-                       goto err_put_dev;
+                       device_unregister(&par_dev->dev);
+                       goto err_put_port;
                }
                port->flags |= PARPORT_FLAG_EXCL;
        }