From ba6585847ebc432e0c808c2bd194e620017b5901 Mon Sep 17 00:00:00 2001 From: Todd Poynor <toddpoynor@google.com> Date: Tue, 17 Jul 2018 13:56:45 -0700 Subject: [PATCH] staging: gasket: remove driver registration on class creation failure 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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index b69b630f1b79..cbadab7544c8 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -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 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) fail1: class_destroy(internal->class); +unregister_gasket_driver: g_descs[desc_idx].driver_desc = NULL; return ret; } -- 2.30.9