Re: [RFC/PATCH 2/3] usb: gadget: introduce UDC Class

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

 



* Michal Nazarewicz | 2011-05-13 15:07:22 [+0200]:

>On Fri, 13 May 2011 13:05:34 +0200, Felipe Balbi <balbi@xxxxxx> wrote:
>
>>+{
>>+	struct usb_udc		*udc;
>>+	unsigned long		flags;
>>+	int			ret = -ENOMEM;
>>+
>>+	udc = kzalloc(sizeof(*udc), GFP_KERNEL);
>>+	if (!udc)
>>+		goto err1;
>>+
>>+	device_initialize(&udc->dev);
>>+	udc->dev.release = usb_udc_release;
>>+	udc->dev.class = udc_class;
>>+	udc->dev.parent = parent;
>>+	ret = dev_set_name(&udc->dev, "%s", kobject_name(&parent->kobj));
>>+	if (ret)
>>+		goto err2;
>>+
>>+	udc->gadget = gadget;
>>+
>>+	spin_lock_irqsave(&udc_lock, flags);
>>+	list_add_tail(&udc->list, &udc_list);
>>+	spin_unlock_irqrestore(&udc_lock, flags);
>>+
>>+	ret = device_add(&udc->dev);
>>+	if (ret)
>>+		goto err2;
>
>On error, UDC is never removed from the list.
>
>>+
>>+	return 0;
>>+
>>+err2:
>>+	put_device(&udc->dev);
>>+
>
>Memory is never freed.

Good catch.

>>+err1:
>>+	return ret;
>>+}
>>+EXPORT_SYMBOL_GPL(usb_add_gadget);

Sebastian
--
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