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

Re: [cdi-devel] [PATCH] USB 1.1



Hi,

On Thu, Dec 10, 2009 at 6:09 AM,  <max@xxxxxxxxxx> wrote:
> From: Max Reitz <max@xxxxxxxxxx>
>

<snip...>

> +
> +    //EP0 initialisieren
> +    device->ep0 = malloc(sizeof(*device->ep0));
> +    device->ep0->endpoint = malloc(sizeof(struct endpoint_desc));
> +    ep0 = (struct endpoint_desc *)device->ep0->endpoint;
> +    ep0->length = sizeof(struct endpoint_desc);
> +    ep0->descriptor_type = DESC_ENDPOINT;
> +    ep0->endpoint_address = 0;
> +    ep0->attributes = 0;
> +    ep0->max_packet_size = 8;
> +    ep0->interval = 0;
> +    device->ep0->device = device;
> +    device->ep0->data_toggle = 0;

Hmm, wouldn't device->ep0 and device->ep0->endpoint leak here:

<snip>

> +
> +    if (dev_desc->iManufacturer) {
> +        name = usb11_do_control(device, DEV_TO_HOST, NULL, 64, STD_REQUEST,
> +            REC_DEVICE, GET_DESCRIPTOR,
> +            (DESC_STRING << 8) | dev_desc->iManufacturer, 0);
> +        if (name == NULL) {
> +            return;
> +        }
> +        d1printf(" -> Manufacturer: ");
> +        for (int i = 2; i < name[0]; i += 2) {
> +            _d1printf("%c", name[i]);
> +        }
> +        _d1printf("\n");
> +    }

There doesn't appear to be any memory freed in the case of name ==
NULL here? Is this intentional?

Looks good otherwise!

Cheers,
Matt