qemu-devel
[Top][All Lists]
Advanced

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

Re: What is the intended behaviour of usb_host_get_port for root hubs?


From: Ben Leslie
Subject: Re: What is the intended behaviour of usb_host_get_port for root hubs?
Date: Tue, 9 Mar 2021 18:43:54 +1100

On Tue, 9 Mar 2021 at 18:24, Gerd Hoffmann <kraxel@redhat.com> wrote:
On Tue, Mar 09, 2021 at 10:54:15AM +1100, Ben Leslie wrote:
> When usb_host_get_port is called for a root-hub device what string should
> be output in the port parameter?

Just the port number, as string.

(and in case this isn't a root port the hub port number(s) are appended,
separated by a dot).

> The current behaviour writes a string with whatever stack value happened to
> be in the paths stack array.

Huh?  Isn't paths updated by the libusb_get_port_numbers() call?

libusb_get_port_numbers() can return zero (for the root hub); or at least it does
on the Linux systems I tried. If that happens path[0] won't be changed by
libusb_get_port_numbers. The rest of the function assumes that the path is
at least 1 item long and unconditionally access path[0], which isn't true if a root-hub
device is passed to the function.

Of course, reading the current code more carefully, usb_host_get_port is never
actually called with a hub device (let alone a root hub), so I guess it is a valid
assumption that libusb_get_port_numbers will always return at least 1 in the non-error
path. I hit the problem as I was trying to reuse the function with a hub device, so my
bad.

Thanks,

Ben


reply via email to

[Prev in Thread] Current Thread [Next in Thread]