greybus: vibrator: add missing protocol-register error handling
authorJohan Hovold <johan@hovoldconsulting.com>
Tue, 13 Oct 2015 17:10:27 +0000 (19:10 +0200)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 14 Oct 2015 19:08:50 +0000 (12:08 -0700)
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>
drivers/staging/greybus/vibrator.c

index fd40cda565e48c73abbcb0a47e1c224285012237..2b8032653f556ab925638d5ead4c8cd53b51a5e4 100644 (file)
@@ -171,7 +171,16 @@ static __init int protocol_init(void)
        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);