device_create() might fail, so check its return value and react
appropriately.

Signed-off-by: Andrzej Pietrasiewicz <[email protected]>
---
 drivers/usb/gadget/function/f_hid.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/f_hid.c 
b/drivers/usb/gadget/function/f_hid.c
index 25021df..434bce8 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -556,6 +556,7 @@ static int __init hidg_bind(struct usb_configuration *c, 
struct usb_function *f)
 {
        struct usb_ep           *ep;
        struct f_hidg           *hidg = func_to_hidg(f);
+       struct device           *device;
        int                     status;
        dev_t                   dev;
 
@@ -623,10 +624,16 @@ static int __init hidg_bind(struct usb_configuration *c, 
struct usb_function *f)
        if (status)
                goto fail;
 
-       device_create(hidg_class, NULL, dev, NULL, "%s%d", "hidg", hidg->minor);
+       device = device_create(hidg_class, NULL, dev, NULL,
+                              "%s%d", "hidg", hidg->minor);
+       if (IS_ERR(device)) {
+               status = PTR_ERR(device);
+               goto del;
+       }
 
        return 0;
-
+del:
+       cdev_del(&hidg->cdev);
 fail:
        ERROR(f->config->cdev, "hidg_bind FAILED\n");
        if (hidg->req != NULL) {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to