Il 22/03/2012 13:07, Gerd Hoffmann ha scritto:
> @@ -460,7 +462,21 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState 
> *qdev, int indent)
>  static char *usb_get_dev_path(DeviceState *qdev)
>  {
>      USBDevice *dev = USB_DEVICE(qdev);
> -    return g_strdup(dev->port->path);
> +    DeviceState *hcd = qdev->parent_bus->parent;
> +    char *id = NULL;
> +
> +    if ((dev->flags & (1 << USB_DEV_FLAG_FULL_PATH)) &&
> +        hcd && hcd->parent_bus && hcd->parent_bus->info->get_dev_path) {
> +        id = hcd->parent_bus->info->get_dev_path(hcd);
> +    }
> +    if (id) {
> +        int len = strlen(id)+strlen(dev->port->path)+2;
> +        char *ret = g_malloc(len);
> +        snprintf(ret, len, "%s/%s", id, dev->port->path);

You can use g_strdup_printf here, also this is leaking id (I have to fix
it for SCSI too).

> +        return ret;
> +    } else {
> +        return g_strdup(dev->port->path);
> +    }
>  }
>  
>  static char *usb_get_fw_dev_path(DeviceState *qdev)

Paolo

Reply via email to