Skip to contentSkip to conversation

usb: gadget: f_hid: use after free in hidg_alloc_inst()

PATCH New Dan Carpenter 1 participant 1 message Nov 13, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 usb: gadget: f_hid: use after free in hidg_alloc_inst()

We free "opts" on the error path and then dereference it.

Fixes 21a9476a7ba8 ('usb: gadget: hid: add configfs support')
drivers/usb/gadget/function/f_hid.c +1 -0
index 56ca3fc..220035f 100644
@@ -875,6 +875,7 @@ static struct usb_function_instance *hidg_alloc_inst(void)
 		kfree(opts);
 		if (idr_is_empty(&hidg_ida.idr))
 			ghid_cleanup();
+		goto unlock;
 	}
 	config_group_init_type_name(&opts->func_inst.group, "", &hid_func_type);