[PATCHv2 1/8] usb: gadget: f_hid: check return value of class_create

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx>
---
 drivers/usb/gadget/function/f_hid.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index 59ab62c..f3b3e19 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -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) {
-- 
1.9.1

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




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux