greybus: vibrator: add missing protocol-register error handling
Add missing error handling when registering the vibrator protocol during
module init.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
diff --git a/drivers/staging/greybus/vibrator.c b/drivers/staging/greybus/vibrator.c
index fd40cda..2b80326 100644
--- a/drivers/staging/greybus/vibrator.c
+++ b/drivers/staging/greybus/vibrator.c
@@ -171,7 +171,16 @@
if (retval)
return retval;
- return gb_protocol_register(&vibrator_protocol);
+ retval = gb_protocol_register(&vibrator_protocol);
+ if (retval)
+ goto err_class_unregister;
+
+ return 0;
+
+err_class_unregister:
+ class_unregister(&vibrator_class);
+
+ return retval;
}
module_init(protocol_init);