Skip to content
Commit 0448d38c authored by Dan Carpenter's avatar Dan Carpenter Committed by Felipe Balbi
Browse files

usb: gadget: f_hid: fix error handling in ghid_setup()



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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 828f6148
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment