usb: gadget: f_hid: check return value of class_create
authorAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Thu, 6 Nov 2014 10:11:56 +0000 (11:11 +0100)
committerFelipe Balbi <balbi@ti.com>
Thu, 6 Nov 2014 22:18:17 +0000 (16:18 -0600)
class_create() might fail, so check its return value and react
appropriately.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/function/f_hid.c

index 59ab62c..f3b3e19 100644 (file)
@@ -742,6 +742,10 @@ int __init ghid_setup(struct usb_gadget *g, int count)
        dev_t dev;
 
        hidg_class = class_create(THIS_MODULE, "hidg");
+       if (IS_ERR(hidg_class)) {
+               hidg_class = NULL;
+               return PTR_ERR(hidg_class);
+       }
 
        status = alloc_chrdev_region(&dev, 0, count, "hidg");
        if (!status) {