usb: gadget: f_hid: fix error handling in ghid_setup()
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 13 Nov 2014 06:20:59 +0000 (09:20 +0300)
committerFelipe Balbi <balbi@ti.com>
Tue, 18 Nov 2014 14:47:44 +0000 (08:47 -0600)
There were a two issues here.

1) We returned PTR_ERR(NULL) which means success if class_create()
   failed.
2) If alloc_chrdev_region() failed then we should clean up before
   returning.

Also kernel style is to have "error handling" as opposed to "success
handling".  In the original code checking for "if (!status) " is
confusing and this bad style is what lead to bug #2.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/function/f_hid.c

Simple merge