]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
staging: gasket: remove driver registration on class creation failure
authorTodd Poynor <toddpoynor@google.com>
Tue, 17 Jul 2018 20:56:45 +0000 (13:56 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Jul 2018 09:39:47 +0000 (11:39 +0200)
If class_create() fails, remove the gasket driver from the global
registration table.

Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/gasket/gasket_core.c

index b69b630f1b79b0b42f9cc91441f4953483540928..cbadab7544c817318def34ad0c1582f7e5d41fdd 100644 (file)
@@ -335,7 +335,8 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc)
        if (IS_ERR_OR_NULL(internal->class)) {
                gasket_nodev_error("Cannot register %s class [ret=%ld]",
                                   driver_desc->name, PTR_ERR(internal->class));
-               return PTR_ERR(internal->class);
+               ret = PTR_ERR(internal->class);
+               goto unregister_gasket_driver;
        }
 
        /*
@@ -369,6 +370,7 @@ fail2:
 fail1:
        class_destroy(internal->class);
 
+unregister_gasket_driver:
        g_descs[desc_idx].driver_desc = NULL;
        return ret;
 }